Java Reference
In-Depth Information
The XML Schema language is sometimes referred to as XSD , from XML Schema Definition language.
The XML Schema namespace is usually associated with the prefix name xsd , and files containing a defini-
tion for a class of XML documents often have the extension .xsd . You also often see the prefix xs used for
the XML Schema namespace, but in fact you can use anything you like. A detailed discussion of the XML
Schema language is a substantial topic that really requires a whole book to do it justice. I'm just giving you
enough of a flavor of how you define XML document schemas so that you're able to see how it differs from
a DTD.
Defining a Schema
The elements in a schema that defines the structure and content of a class of XML documents are organized
in a similar way to the elements in a DTD. A schema has a single root element that is unique, and all other
elements must be contained within the root element and must be properly nested. Every schema consists of
a schema root element with a number of nested subelements. Let's look at a simple example.
Here's a possible schema for XML documents that contain an address:
<?xml version="1.0" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:annotation>
<xsd:documentation>
This schema defines documents that contain an address.
</xsd:documentation>
</xsd:annotation>
<!--This declares document content. -->
<xsd:element name="address" type="AddressType"/>
Search WWH ::




Custom Search