XML Namespaces Each schema file associated with a

  • Slides: 6
Download presentation
XML Namespaces • Each schema file associated with a URL to uniquely identify where

XML Namespaces • Each schema file associated with a URL to uniquely identify where elements come from – Like packages in Java http: //www. ebay. com http: //www. amazon. com http: //www. superstore. ca

Target. Namesapce • So, if I’m writing a schema for my superstore <schema. .

Target. Namesapce • So, if I’m writing a schema for my superstore <schema. . . target. Namespace=“http: //www. superstore. com” >

Label prefixes • Instead of referring to URLs, namespaces are given short prefix labels

Label prefixes • Instead of referring to URLs, namespaces are given short prefix labels <schema. . . target. Namespace=“http: //www. superstore. ca” xmlns: ebay=http: //www. ebay. com > <element name=“e. Bay. Product” ref=“ebay: Product” /> </schema>

Referring to XML Schema schema • XML Schema is an XML language itself with

Referring to XML Schema schema • XML Schema is an XML language itself with a schema. <xs: schema target. Namespace=“http: //www. superstore. ca” xmlns: ebay=http: //www. ebay. com” xmlns: xs=“http: //www. w 3. org/2001/XMLSchema” > <xs: element name=“e. Bay. Product” type=“ebay: Product”/> </xs: schema>

Default Namespace • One namespace can be given no label, for convenience <schema. .

Default Namespace • One namespace can be given no label, for convenience <schema. . . target. Namespace=“http: //www. superstore. ca” xmlns: ebay=http: //www. ebay. com” xmlns=“http: //www. w 3. org/2001/XMLSchema” > <element name=“e. Bay. Product” type=“ebay: Product”/> </schema>

Declarations • Prefixes are not used when declaring names of elements or types •

Declarations • Prefixes are not used when declaring names of elements or types • Prefixes are used when referring to elements or types <schema. . . target. Namespace=“http: //www. superstore. ca” xmlns: ebay=http: //www. ebay. com” xmlns=“http: //www. w 3. org/2001/XMLSchema” > <element name=“e. Bay. Product” type=“ebay: Product”/> </schema>