File: Data.xml
<?xml version="1.0"?>
<library xmlns="http://java2s.com/ns/library">
<book id="b0836217462" available="yes">
<isbn>0836217462</isbn>
<title>Java</title>
<authors>
<person id="CMS">
<name>name 1</name>
<born>1956-11-26</born>
<dead>2000-02-12</dead>
</person>
</authors>
<characters>
<person id="PP">
<name>Swing</name>
<born>1966-08-22</born>
<qualification>GUI</qualification>
</person>
<person id="Snoopy">
<name>Database</name>
<born>1950-10-04</born>
<qualification>JDBC</qualification>
</person>
</characters>
</book>
</library>
File: Schema.xsd
<?xml version="1.0"?>
<xs:schema targetNamespace="http://java2s.com/ns/library"
elementFormDefault="qualified" attributeFormDefault="unqualified"
xmlns:lib="http://java2s.com/ns/library"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="library">
<xs:complexType>
<xs:sequence>
<xs:element name="book" type="lib:bookType" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="person">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string" />
<xs:element name="born" type="xs:date" />
<xs:element name="dead" type="xs:date" minOccurs="0" />
<xs:element name="qualification" type="xs:string"
minOccurs="0" />
</xs:sequence>
<xs:attribute name="id" type="xs:ID" use="required" />
</xs:complexType>
</xs:element>
<xs:complexType name="bookType">
<xs:sequence>
<xs:element name="isbn" type="xs:NMTOKEN" />
<xs:element name="title" type="xs:string" />
<xs:element name="authors">
<xs:complexType>
<xs:sequence>
<xs:element ref="lib:person"
maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="characters">
<xs:complexType>
<xs:sequence>
<xs:element ref="lib:person"
maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:ID" use="required" />
<xs:attribute name="available" type="xs:string" use="required" />
</xs:complexType>
</xs:schema>
|