Schema Parts
The simple schemas in Examples Example C-2 and Example C-3 use a lot of pieces of XSD, and you can use them as models for future schemas, but there are a lot more options available, even in the most readily usable subset of XSD.
Namespaces
The only namespace declaration to appear in either example was the namespace declaration for XSD itself:
xmlns:xs="http://www.w3.org/2001/XMLSchema"
In this case, the schema was defining a vocabulary that was not in a
namespace, so there was no need to define an additional namespace.
If, as is typical, your schemas define vocabularies that are in a
namespace, you’ll need to define the namespace on
the root xs:schema
element. Example C-4 shows a
slightly modified version of Example C-3, defining the vocabulary as
belonging to the http://simonstl.com/ns/authors/
namespace. Changes to the schema appear in bold.
Example C-4. Example C-3 rewritten to support a namespace
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://simonstl.com/ns/authors/" xmlns="http://simonstl.com/ns/authors/" elementFormDefault="qualified" attributeFormDefault="unqualified" > <xs:element name="authors"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" ref="person"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="person"> <xs:complexType> <xs:sequence minOccurs="0"> <xs:element ref="name"/> <xs:element ref="nationality"/> </xs:sequence> <xs:attribute ref="id" use="required"/> ...
Get Office 2003 XML now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.