dev@jaxb.java.net

Re: Error occurs when converting XML schema to Java objects

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Thu, 01 Mar 2007 09:56:00 -0800

Your schema fragment didn't compile because I don't have two types
referenced from there, so I modified it as follows, and that compiled
just fine.

So I think if you still see this problem you should file an issue with a
complete schema as an attachment.


modified schema:

<xs:schema targetNamespace="http://www.opengis.net/swe"
     xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
     xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
     jaxb:extensionBindingPrefixes="xjc"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     xmlns:swe="http://www.opengis.net/swe"
     elementFormDefault="qualified"
     attributeFormDefault="unqualified"
     jaxb:version="2.1" >


     <!--============================-->

     <!-- Main Substitution Groups -->

     <!--============================-->

     <xs:element name="_DataGroup" type="xs:anyType" abstract="true">
         <xs:annotation>
             <xs:appinfo>
                     <xjc:substitutable />
               </xs:appinfo>
         </xs:annotation>
     </xs:element>

     <xs:element name="_DataArray" type="xs:anyType" abstract="true">
         <xs:annotation>
             <xs:appinfo>
                     <xjc:substitutable />
             </xs:appinfo>
         </xs:annotation>
     </xs:element>
</xs:schema>


Peizhao Hu wrote:
> Hi,
>
> I tried to use JAXB RI 2.1.2 to bind a set of xml schema. however, It
> failed when binding "substitutionGroup", I have modified the schema
> with customisation annotations as shown below, however, it still
> generate errors. I searched on google for this errors, but no luck. do
> you have any idea?
>
>
> //====================== Error ===================
> SensorML_examples/schemas/sweCommon/1.0.30$ xjc.sh parameters.xsd -extension
> parsing a schema...
> [ERROR] compiler was unable to honor this substitutable customization.
> It is attached to a wrong place, or its inconsistent with other bindings.
> line 26 of
> file:/home/phu/programming/SensorML_examples/schemas/sweCommon/1.0.30/parameters.xsd
>
> [ERROR] (the above customization is attached to the following location
> in the schema)
> line 23 of
> file:/home/phu/programming/SensorML_examples/schemas/sweCommon/1.0.30/parameters.xsd
>
> [ERROR] compiler was unable to honor this substitutable customization.
> It is attached to a wrong place, or its inconsistent with other bindings.
> line 33 of
> file:/home/phu/programming/SensorML_examples/schemas/sweCommon/1.0.30/parameters.xsd
>
> [ERROR] (the above customization is attached to the following location
> in the schema)
> line 30 of
> file:/home/phu/programming/SensorML_examples/schemas/sweCommon/1.0.30/parameters.xsd
>
> Failed to parse a schema.
>
>
>
>
> //====================== schema ===================
> <xs:schema targetNamespace="http://www.opengis.net/swe"
> xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
> xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
> jaxb:extensionBindingPrefixes="xjc"
> xmlns:xlink="http://www.w3.org/1999/xlink"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:swe="http://www.opengis.net/swe"
> elementFormDefault="qualified"
> attributeFormDefault="unqualified"
> jaxb:version="2.1" >
>
>
> <!--============================-->
>
> <!-- Main Substitution Groups -->
>
> <!--============================-->
>
> <xs:element name="_DataGroup" type="swe:_GroupBaseType" abstract="true">
> <xs:annotation>
> <xs:appinfo>
> <xjc:substitutable />
> </xs:appinfo>
> </xs:annotation>
> </xs:element>
>
> <xs:element name="_DataArray" type="swe:_ArrayBaseType" abstract="true">
> <xs:annotation>
> <xs:appinfo>
> <xjc:substitutable />
> </xs:appinfo>
> </xs:annotation>
> </xs:element>
>


-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com