26-Jan-05 (Created: 26-Jan-05) | More in 'CS-xml'

jaxb: Sample XML and XSD file

Sample XML

<?xml version="1.0" encoding="UTF-8"?>
<DCETemplateLayout>
<Section>
   <SectionID>1</SectionID>
   <DocumentID>15</DocumentID>
   <SectionTitle>Product Introduction</SectionTitle>
   <ParentID>0</ParentID>
   <Ordinal>0</Ordinal>
   <KeyDescription/>
   <KeyDefinition/>
   <Section>
      <SectionID>2</SectionID>
      <DocumentID>10</DocumentID>
      <SectionTitle>BlueOptions Intro</SectionTitle>
      <ParentID>1</ParentID>
      <Ordinal>0</Ordinal>
      <KeyDescription>Product</KeyDescription>
      <KeyDefinition>XPATH</KeyDefinition>
      <Content>
         <QualificationKey>BO</QualificationKey>
         <Document>Blue Options Product Intro</Document>
      </Content>
   </Section>
   <Content>
      <QualificationKey/>
      <Document/>
   </Content>
</Section>
</DCETemplateLayout>

Sample XSD

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
            xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
            jxb:version="1.0"
         elementFormDefault="qualified" 
         attributeFormDefault="unqualified">
<xs:complexType name="ContentType">
   <xs:all>
      <xs:element name="QualificationKey" type="xs:string"/>
      <xs:element name="Document" type="xs:string"/>
   </xs:all>
</xs:complexType>

<xs:complexType name="SectionType">
      <xs:sequence>
         <xs:element name="SectionID" type="xs:long"/>
         <xs:element name="DocumentID" type="xs:string"/>
         <xs:element name="SectionTitle" type="xs:string"/>
         <xs:element name="ParentID" type="xs:long"/>
         <xs:element name="Ordinal" type="xs:long"/>
         <xs:element name="KeyDescription" type="xs:string"/>
         <xs:element name="KeyDefinition" type="xs:string"/>
         <xs:element name="Section" type="SectionType" minOccurs="0" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:appinfo>
                        <jxb:property name="Sections"/>
                    </xs:appinfo>
                </xs:annotation>
         </xs:element>         
         <xs:element name="Content" type="ContentType" minOccurs="0" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:appinfo>
                        <jxb:property name="Contents"/>
                    </xs:appinfo>
                </xs:annotation>
         </xs:element>                
      </xs:sequence>      
</xs:complexType>

<xs:element name="DCETemplateLayout">
<xs:complexType>
      <xs:sequence>
         <xs:element name="Section" type="SectionType" minOccurs="1" />
      </xs:sequence>
</xs:complexType>      
</xs:element>

</xs:schema>