A book element of our library : Russian Doll « XML Schema « XML Tutorial






File:Data.xml
<book xmlns="http://www.java2s.com"
     identifier="isbn-0836217462">
  <isbn>0836217462</isbn>
  <title>Java</title>
  <author-ref ref="anotherRef" />
  <chapter-refs>
    ref
  </chapter-refs>
</book>


File: Schema.xsd

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.java2s.com" xmlns="http://www.java2s.com"
  elementFormDefault="qualified">

  <xs:element name="book">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="isbn" type="xs:string" />
        <xs:element name="title" type="xs:string" />
        <xs:element name="author-ref">
          <xs:complexType>
            <xs:attribute name="ref" type="xs:string"
              use="required" />
          </xs:complexType>
        </xs:element>
        <xs:element name="chapter-refs" type="xs:string" />
      </xs:sequence>
      <xs:attribute name="identifier" type="xs:ID" use="required" />
    </xs:complexType>
  </xs:element>
</xs:schema>








3.97.Russian Doll
3.97.1.Russian Doll and Object-Oriented Design
3.97.2.Russian Doll design nest the local element declaration within other schema component
3.97.3.Russian doll type element
3.97.4.Adapting the structure of your document
3.97.5.A book element of our library