users@jaxb.java.net

Global versus local binding customizations

From: Alistair Todd <atodd917_at_yahoo.co.uk>
Date: Thu, 18 Dec 2003 15:42:54 +0000 (GMT)

Hello,
 
I have encountered a problem with JAXB1.0.2 (JWSDP1.3) that didn't exist with 1.0 (JWSDP1.1).
 
I have a global JavaType binding customization that applies to xs:string. This is fine for all except some xs:string elements in a complex type that I don't want to be customized. so, I have a local binding customization for the xs:string elements in that complex type, to apply the standard conversion to java String.
 
In 1.0, this works fine, and all xs:strings are converted to a custom type according to the global custom binding, but the odd ones inside the custom type are converted as standard to java Strings.

In 1.0.2, xjc reports:-

[ERROR] Specified conversion customization is not used.

and the compilation fails. It appears that it is no longer possible to have a local customization that overrides a global one. Unless I am doing something wrong. If there was a way to specify a custom binding for an entire complex type, then I could do that, but there isn't. Or doesn't seem to be.

Either way, I can find no documentation at all, anywhere, to explain what the problem is, how to avoid it, whether what I'm trying is possible or not, and so I am stuck.

Any help greatly appreciated.

Here's a cut down version of the schema with the pertinent items. I want the TITLE element (and a whole bunch of other elements, all xs:string, removed for clarity) to be converted using the custom datatype converter, but I want the xs:string elements inside FILELIST to be converted to java Strings in the normal manner.

<?xml version="1.0" encoding="UTF-8"?>



<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

xmlns:jxb="http://java.sun.com/xml/ns/jaxb"

jxb:version="1.0">





<xs:annotation>

<xs:appinfo>

<jxb:globalBindings>

<jxb:javaType

name="org.omg.CORBA.Any"

xmlType="xs:string"

parseMethod="com.whatever.MyDataTypeConverter.parseString"

printMethod="com.whatever.MyDataTypeConverter.printString"

/>





</jxb:globalBindings>

</xs:appinfo>

</xs:annotation>







<xs:element name="QUERYRESULTS">

<xs:complexType>

<xs:sequence>

<xs:element ref="QUERYRESULT" minOccurs="0" maxOccurs="unbounded" />

</xs:sequence>

</xs:complexType>

</xs:element>



<xs:element name="QUERYRESULT">

<xs:complexType>

<xs:sequence>

<xs:element ref="FILELIST" minOccurs="0" />

<xs:element ref="TITLE" minOccurs="0" />

<!-- lots of bits removed for clarity -->

</xs:sequence>

</xs:complexType>

</xs:element>



<xs:element name="FILELIST">

<xs:complexType>

<xs:sequence minOccurs="1" maxOccurs="unbounded">

<xs:element ref="NAMENAME"/>

</xs:sequence>

</xs:complexType>

</xs:element>

<xs:element name="TITLE" type="xs:string"/>





<xs:element name="FILELIST">

<xs:complexType>

<xs:sequence>

<xs:element name="NAME1" type="xs:string">

<xs:annotation>

<xs:appinfo>

<jxb:javaType

name="java.lang.String"

parseMethod="javax.xml.bind.DatatypeConverter.parseString"

printMethod="javax.xml.bind.DatatypeConverter.printString"

/>

</xs:appinfo>

</xs:annotation>

</xs:element>

<xs:element name="NAME2" type="xs:string">

<xs:annotation>

<xs:appinfo>

<jxb:javaType

name="java.lang.String"

parseMethod="javax.xml.bind.DatatypeConverter.parseString"

printMethod="javax.xml.bind.DatatypeConverter.printString"

/>

</xs:appinfo>

</xs:annotation>

</xs:element>

</xs:sequence>

</xs:complexType>

</xs:element>





</xs:schema>

 


---------------------------------
  Yahoo! Messenger - Communicate instantly..."Ping" your friends today! Download Messenger Now