You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xmlbeans.apache.org by "Shobha Srinivasan (shsriniv)" <sh...@cisco.com> on 2004/09/14 22:46:21 UTC

Issue with in derived complex types

Hi,
 
The <xb:suffix> and <xb:qname> in the xsdconfig file do not seem to work
properly 
 
1. when a type is derived from another type and has the same name as the
base type
and
2. when the name of the element of above type is same as the name of the
type
and
3. when one uses <xb:qname> and <xb:suffix> in xsdconfig file
 
The Java classes for types do no have the suffixes mentioned in the
config file.
 
The xsd files uses, the xsdconfig file used and the exact issue is
explained below. Is this a bug?
 
Thanks and Regards
Shobha
 
------------------------ types/Party.xsd file --------------------------
<xsd:schema targetNamespace="http://www.examples.com/types"
elementFormDefault="qualified" attributeFormDefault="unqualified"
xmlns="http://www.examples.com/types"
xmlns:types="http://www.examples.com/types"
xmlns:ntypes="http://www.examples.com/ntypes"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <xsd:element name="Party" type="types:PartyType" />
 <xsd:complexType name="PartyType">
  <xsd:complexContent>
   <xsd:extension base="ntypes:Party" />
  </xsd:complexContent>
 </xsd:complexType>
 <xsd:element name="Name" type="types:NameType"
substitutionGroup="ntypes:Name" />
 <xsd:complexType name="NameType">
  <xsd:complexContent>
   <xsd:extension base="ntypes:Name">
    <xsd:sequence>
     <xsd:element name="MiddleName" type="xsd:string"/>
    </xsd:sequence>
   </xsd:extension>
  </xsd:complexContent>
 </xsd:complexType>
</xsd:schema>
 
------------------------ ntypes/Party.xsd file
--------------------------
<xsd:schema targetNamespace="http://www.examples.com/ntypes"
elementFormDefault="qualified" attributeFormDefault="unqualified"
xmlns="http://www.examples.com/ntypes"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <xsd:element name="Party" type="Party" />
 <xsd:complexType name="Party">
  <xsd:sequence>
   <xsd:element ref="Name"/>
  </xsd:sequence>
 </xsd:complexType>
 <xsd:element name="CustomerParty" type="Party"
substitutionGroup="Party" />
 <xsd:element name="Name" type="Name" />
 <xsd:complexType name="Name">
  <xsd:sequence>
   <xsd:element ref="FirstName" />
   <xsd:element ref="LastName" />
  </xsd:sequence>
 </xsd:complexType>
 <xsd:simpleType name="FirstName">
  <xsd:restriction base="xsd:string" />
 </xsd:simpleType>
 <xsd:element name="FirstName" type="FirstName" />
 <xsd:simpleType name="LastName">
  <xsd:restriction base="xsd:string" />
 </xsd:simpleType>
 <xsd:element name="LastName" type="LastName" />
</xsd:schema>
 
------------------------ types/Party.xsdconfig file
--------------------------
 
<xb:config xmlns:types="http://www.examples.com/types" 
    xmlns:xb="http://www.bea.com/2002/09/xbean/config">
 
    <xb:qname name="types:Party" javaname="PartyElement"/>
    <xb:qname name="types:Name" javaname="NameElement"/>
 
    <!-- Use the "namespace" element to map a namespace to the Java
package
        name that should be generated. -->
    <xb:namespace uri="http://www.examples.com/types">
        <xb:package>example.types</xb:package>
        <xb:suffix>ComplexType</xb:suffix>
    </xb:namespace>
 
    <xb:namespace uri="http://www.examples.com/ntypes">
        <xb:package>example.ntypes</xb:package>
    </xb:namespace>
 
</xb:config>
 
---------------------- Command to generate source
--------------------------
scomp -src src -d classes -out pty.jar -verbose Party.xsd
Party.xsdconfig
 
----------------------- The Problem -------------------------
 
The xsdconfig <xb:suffix> documenation says that A suffix to be used to
append to top-level Java type names generated in this namespace. (The
suffix is not used for inner Java type definitions.).
 
With the above xsds and xsdconfig files, the classes generated (apart
from $factory) are:
Classes in package example.types
 NameElement.class
 NameTypeComplexType.class
 PartyElement.class
 PartyTypeComplexType.class

Classes in package example.ntypes
 CustomerPartyDocument.class
 FirstName.class
 FirstNameDocument.class
 LastName.class
 LastNameDocument.class
 Name.class
 NameDocument.class
 Party.class
 PartyDocument.class
 
In example.types package, Name element in schema is converted into
NameElement java name according to the qname configuration and NameType
complexType is converted into NameTypeComplexType java name according to
the suffix configuration.
 
The issue is that if the types/Party.xsd is modified to use the same
name for element and complexType like
 
<xsd:schema targetNamespace="http://www.examples.com/types"
elementFormDefault="qualified" attributeFormDefault="unqualified"
xmlns="http://www.examples.com/types"
xmlns:types="http://www.examples.com/types"
xmlns:ntypes="http://www.examples.com/ntypes"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <xsd:element name="Party" type="types:Party" />
 <xsd:complexType name="Party">
  <xsd:complexContent>
   <xsd:extension base="ntypes:Party" />
  </xsd:complexContent>
 </xsd:complexType>
 <xsd:element name="Name" type="types:Name"
substitutionGroup="ntypes:Name" />
 <xsd:complexType name="Name">
  <xsd:complexContent>
   <xsd:extension base="ntypes:Name">
    <xsd:sequence>
     <xsd:element name="MiddleName" type="xsd:string"/>
    </xsd:sequence>
   </xsd:extension>
  </xsd:complexContent>
 </xsd:complexType>
</xsd:schema>
 
contained the name of the complexType also as "Name" and name of Party ,
then the classes generated in example.types package are
 
NameElement.java
NameElement2.java
PartyElement.java
PartyElement2.java
 
Why is the name of the element and complex type making this difference?
 
The same result is achieved even when we do not remove
        <xb:suffix>ComplexType</xb:suffix>
from the configuration file. This does not seem to have any affect.