Andrew Hughes wrote:
> 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.
Yeah, that sounds really like a bug of schema.
> 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.
Hmm. I tried it locally and it seems to work just fine. I attached a sample.
Do you get any error message? Does XJC silently ignores your binding?
--
Kohsuke Kawaguchi
Sun Microsystems kohsuke.kawaguchi_at_sun.com
<bindings
xmlns="
http://java.sun.com/xml/ns/jaxb"
xmlns:xs="
http://www.w3.org/2001/XMLSchema"
version="2.0">
<bindings schemaLocation="test.xsd" node="/xs:schema/xs:complexType[@name='Foo']/xs:attribute[@name='foo']">
<property name="foo">
<baseType>
<javaType name="java.lang.String" />
</baseType>
</property>
</bindings>
</bindings>