users@jaxb.java.net

Recursive schema?

From: David Halonen <david.halonen_at_compuware.com>
Date: Mon, 31 Mar 2003 11:38:42 -0700

Does anyone have experience making a recursive structure/schema such as:

1. Purchase order type has a new element appended.

<xsd:complexType name="PurchaseOrderType">
  <xsd:sequence>
    <xsd:element name="shipTo" type="USAddress"/>
    <xsd:element name="billTo" type="USAddress"/>
    <xsd:element ref="comment" minOccurs="0"/>
    <xsd:element name="items" type="Items"/>
    <xsd:element name="foo" type="fooType"/>
  </xsd:sequence>
  <xsd:attribute name="orderDate" type="xsd:date"/>
</xsd:complexType>


2. fooType is defined as:

<xsd:complexType name="fooType">
  <xsd:sequence>
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
        <xsd:element name="fee" minOccurs="0" maxOccurs="unbounded" type="xsd:string"/>
        <xsd:element name="foo" minOccurs="0" maxOccurs="unbounded" type="fooType"/>
    </xsd:choice>
  </xsd:sequence>
  <xsd:attribute name="myFooName" type="xsd:string"/>
</xsd:complexType>

3. The po.xml file changed to:

<?xml version="1.0"?>
<purchaseOrder orderDate="1999-10-20">
 <shipTo country="US">
  <name>Alice Smith</name>
  <street>123 Maple Street</street>
  <city>Cambridge</city>
  <state>MA</state>
  <zip>12345</zip>
 </shipTo>
 <billTo country="US">
  <name>Robert Smith</name>
  <street>8 Oak Avenue</street>
  <city>Cambridge</city>
  <state>MA</state>
  <zip>12345</zip>
 </billTo>
 <items>
  <item partNum="242-NO">
   <productName>Nosferatu - Special Edition (1929)</productName>
   <quantity>5</quantity>
   <USPrice>19.99</USPrice>
  </item>
  <item partNum="242-MU">
   <productName>The Mummy (1959)</productName>
   <quantity>3</quantity>
   <USPrice>19.98</USPrice>
  </item>
  <item partNum="242-GZ">
   <productName>Godzilla and Mothra: Battle for Earth/Godzilla vs. King Ghidora</productName>
   <quantity>3</quantity>
   <USPrice>27.95</USPrice>
  </item>
 </items>
    <foo myFooName="foo 1">
        <fee>Fee 1</fee>
        <foo myFooName="foo 2">
            <fee>Fee 2</fee>
            <foo myFooName="foo 3">
                <fee>Fee 3 </fee>
            </foo>
        </foo>
    </foo>
</purchaseOrder>

Does JAXB support such a type definition? Is this definition doable?

TIA,
David Halonen
Compuware
248.737.7300 ext 13578