users@jaxb.java.net

Binding an Attributes JavaType via External Customization

From: Andrew Hughes <azza_at_lisasoft.com>
Date: Wed, 12 Apr 2006 17:10:58 +0930

Hey List,

Im trying to implement an Open Standard WebService. This means that I
can't modify the xsd's to solve the problem, and also cant do the
customization inline.

My problem is that my incoming document contains a "legal" attribute value:
            version="1.1.0"

However JAXB is binding the attibute to the type BigDecimal... and this
will only work with values "1.0","1.1", eta... not "1.1.1" or "1.1.0". I
know this is really a fault of the xsd, but i cant change the xsd.

A snippet of the xsd looks like...

------------------------------------------------------------------------------------
    <complexType name="BASEType">
        <attribute name="version" type="decimal" use="required"/>
        <!-- other suff I dont care about removed -->
    </complexType>
------------------------------------------------------------------------------------


My External Customization Currently is this, but its still using
BigDecimal :(
------------------------------------------------------------------------------------
<jxb:bindings version="1.0"
               xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
               xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <jxb:bindings schemaLocation="BASE.xsd" node="/xs:schema">
        <!-- version was decimal but doesnt work with x.x.x only x.x -->
        <jxb:bindings
node="//xs:complexType[@name='BASEType']//xs:attribute[@name='version']">
             <!-- START OF STUFF NOT WORKING FOR ME -->
             <jxb:property name="version">
                 <jxb:baseType name="java.lang.String">
                    <jxb:javaType name="java.lang.String"
parseMethod="new" printMethod="toString" />
                 </jxb:baseType>
             </jxb:property>
             <!-- END OF STUFF NOT WORKING FOR ME -->
            </jxb:bindings>
    </jxb:bindings>
</jxb:bindings>
------------------------------------------------------------------------------------

It looks like I am using the wrong operation (<jxb:property>) to achieve
this... can someone help me out with an xjb solution please.


Thanks in Advance

Az