You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Menno Jansz <me...@jansz.com> on 2008/04/10 13:04:13 UTC
How to avoid inner class generation for anonymous complex types?
Hi,
Is there a way to tell scomp to avoid using inner classes for anonymous complex
types, but instead treat them as it would top-level types, using as a name the
surrounding element name?
As an example I have the following for PRODUCT1 in the first xsd:
<xs:element name="PRODUCT1">
<xs:complexType>
<xs:sequence>
<xs:element name="id" minOccurs="0">
<xs:complexType>
<xs:attribute name="productname" type="xs:string" use="required" />
<xs:attribute name="productid" type="xs:integer" use="required" />
</xs:complexType>
</xs:element>
<xs:element name="details" minOccurs="0">
<xs:complexType>
<xs:attribute name="detail1" type="xs:string" use="required" />
<xs:attribute name="detail2" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
<xs:element name="product1spec" minOccurs="0">
<xs:complexType>
<xs:attribute name="blah1" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element
and similarly in the second xsd PRODUCT2:
<xs:element name="PRODUCT2">
<xs:complexType>
<xs:sequence>
<xs:element name="id" minOccurs="0">
<xs:complexType>
<xs:attribute name="productname" type="xs:string" use="required" />
<xs:attribute name="productid" type="xs:integer" use="required" />
</xs:complexType>
</xs:element>
<xs:element name="details" minOccurs="0">
<xs:complexType>
<xs:attribute name="detail1" type="xs:string" use="required" />
<xs:attribute name="detail2" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
<xs:element name="product2spec" minOccurs="0">
<xs:complexType>
<xs:attribute name="blah2" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
Now when I run scomp this will for example generate an inner classes for Id as
PRODUCT1Document.PRODUCT1.Id, and PRODUCT2Document.PRODUCT2.Id. Really I would
like to have the same Id class for both xsds. Is this possible?
I really want to treat these anonymous complex types as if the xsd files were as
follows (and I run scomp with -allowmdef):
<xs:element name="PRODUCT1">
<xs:complexType>
<xs:sequence>
<xs:element name="id" type="id" minOccurs="0">
</xs:element>
<xs:element name="details" type="details" minOccurs="0">
</xs:element>
<xs:element name="product1spec" type="productspec1" minOccurs="0">
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="id">
<xs:attribute name="productname" type="xs:string" use="required" />
<xs:attribute name="productid" type="xs:integer" use="required" />
</xs:complexType>
<xs:complexType name="details">
<xs:attribute name="detail1" type="xs:string" use="required" />
<xs:attribute name="detail2" type="xs:string" use="required" />
</xs:complexType>
<xs:complexType name="productspec1">
<xs:attribute name="blah1" type="xs:string" use="required" />
</xs:complexType>
Any ideas on how to do this would be appreciated. Ideally I would change the
schemas as above, but I have no control over the schemas as they come from a
third party system and there are thousands.
Cheers,
Menno
--
www.jansz.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org