position
Technology : XML
XML Schema

Custom XML Namespaces

XML Schemas provide a means for defining the structure, content and semantics of XML documents.

For instance, the following markup complies with a schema identified by the namespace “http://www.torrent-universe.com/schema/Page.xsd”.

<Page xmlns="http://www.torrent-universe.com/schema/Page.xsd">
<Title>
<Paragraph Language="English">XML Schema</Paragraph>
<Paragraph Language="French">Schémas XML</Paragraph>
</Title>
<Subtitle>
<Paragraph Language="English">Custom XML Namespaces</Paragraph>
<Paragraph Language="French">Création de languages XML Personnalisés</Paragraph>
</Subtitle>
<Abstract>
<Paragraph Language="English">XML Schemas provide a means for defining the structure, content and semantics of XML documents.</Paragraph>
<Paragraph Language="French">Les schémas XML permettent de définir des structures de documents XML.</Paragraph>
</Abstract>
<Body>
<Paragraph Language="English">This document complies with the “http://www.torrent-universe.com/schema/Page.xsd” namespace.</Paragraph>
<Paragraph Language="French">Ce document repecte la définition “http://www.torrent-universe.com/schema/Page.xsd”.</Paragraph>
</Body>
</Page>

The document definition for “http://www.torrent-universe.com/schema/Page.xsd” can be expressed in the w3 XML Schema language.

<xsd:schema targetNamespace="http://www.torrent-universe.com/schema/Page.xsd" xmlns="http://www.torrent-universe.com/schema/Page.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xsd:element name="Page" type="typePage"/>
<xsd:element name="Title" type="typeParagraphs"/>
<xsd:element name="Subtitle" type="typeParagraphs"/>
<xsd:element name="Abstract" type="typeParagraphs"/>
<xsd:element name="Body" type="typeParagraphs"/>
<xsd:element name="Paragraph" type="typeParagraph"/>
<xsd:complexType name="typePage">
<xsd:sequence minOccurs="0" maxOccurs="1">
<xsd:element ref="Title" minOccurs="1" maxOccurs="1"/>
<xsd:element ref="Subtitle" minOccurs="0" maxOccurs="1"/>
<xsd:element ref="Abstract" minOccurs="0" maxOccurs="1"/>
<xsd:element ref="Body" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="typeParagraphs">
<xsd:sequence minOccurs="0" maxOccurs="unbounded">
<xsd:element ref="Paragraph" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="typeParagraph" mixed="true">
<xsd:attribute name="Language" use="optional" type="typeLanguage"/>
</xsd:complexType>
<xsd:simpleType name="typeLanguage">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="English"/>
<xsd:enumeration value="French"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>

Additional Information on XML Schema :

w3 Recommendation