users@jaxb.java.net

JAXB issue on referenced elements under anonymous complex types

From: Juan Cruz <cruz.juanito31_at_gmail.com>
Date: Tue, 19 Apr 2011 14:43:35 +0800

I'm having issues when generating the wsdl, wherein a schema definition was
not imported.
Here are the sample xsd that I used to generate the Jaxb java artifacts
which are then used to create the wsdl.


Here is a sample of the main XSD used.
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http:/
sample.com/mainXSD" xmlns:price="http:/sample.com/price"
xmlns:product="http:/sample.com/product" targetNamespace="http:/
sample.com/mainXSD" elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:import namespace="http:/sample.com/price" schemaLocation="price.xsd" />
<xs:import namespace="http:/sample.com/product" schemaLocation="product.xsd"
/>
<xs:complexType name="ProductDetails">
  <xs:annotation>
   <xs:documentation>ProductDetails</xs:documentation>
  </xs:annotation>
  <xs:sequence>
   <xs:element name="Description">
    <xs:annotation>
     <xs:documentation>Description</xs:documentation>
    </xs:annotation>
    <xs:complexType>
     <xs:complexContent>
      <xs:extension base="product:Identification">
       <xs:sequence minOccurs="0">
        <xs:element name="ProductPrice">
         <xs:annotation>
          <xs:documentation>ProductPrice</xs:documentation>
         </xs:annotation>
         <xs:complexType>
          <xs:sequence>
           <xs:element ref="price:WholePrice"/>
           <xs:element ref="price:RetailPrice"/>
          </xs:sequence>
         </xs:complexType>
        </xs:element>
       </xs:sequence>
      </xs:extension>
     </xs:complexContent>
    </xs:complexType>
   </xs:element>
  </xs:sequence>
 </xs:complexType>

 price.xsd
 [......]
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http:/sample.com/price" elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:element name="WholePrice" type="xs:string">
    <xs:annotation>
        <xs:documentation>Wholesale Price.</xs:documentation>
    </xs:annotation>
</xs:element>
<xs:element name="RetailPrice" type="xs:string">
    <xs:annotation>
        <xs:documentation>RetailPrice.</xs:documentation>
    </xs:annotation>
</xs:element>
[...]


Product.xsd

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http:/sample.com/product" elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:complexType name="Identification">
  <xs:annotation>
   <xs:documentation>Identification</xs:documentation>
  </xs:annotation>
  <xs:sequence>
   <xs:element name="Type" type="xs:string">
    <xs:annotation>
     <xs:documentation>Product Type</xs:documentation>
    </xs:annotation>
   </xs:element>
   <xs:element name="Category" type="xs:string">
    <xs:annotation>
     <xs:documentation>Category.</xs:documentation>
    </xs:annotation>
   </xs:element>
  </xs:sequence>
 </xs:complexType>



When I checked the generated wsdl it does not contain schema definition for
namespace "http:/sample.com/price".
Is there a limitation or is this a bug wherein Jaxb will not import the
schema definition for referenced elements that are defined under anonymous
complex types?