users@jaxb.java.net

Re: How to map xs:integer to java.lang.Integer within jxb:bindings jxb:bindings?

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Thu, 8 Jan 2009 12:07:26 +0100

The easiest way would be to take the generated Adapter1.java, refactor it
any way you like, and change the customization to one that explicitly
specifies the attributes parseMethod and printMethod in <jxb:javaType>.
These two attribute values consist of <package>.<class>.<method>.

-W

On Thu, Jan 8, 2009 at 5:13 AM, <removeps-groups_at_yahoo.com> wrote:

> How to map xs:integer to java.lang.Integer within jxb:bindings
> jxb:bindings?
>
> On the web there are examples of how to do this within the xsd, using
> xs:annotation and so forth. But I'd like to do it through an external
> bindings file.
>
> Using jxb:globalBindings within jxb:bindings works:
>
> <jxb:bindings version="1.0"
> xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
> <jxb:globalBindings>
> <jxb:javaType name="java.lang.Integer" xmlType="xs:integer"/>
> </jxb:globalBindings>
> <jxb:bindings schemaLocation="mydef.xsd" node="/xs:schema">
> <jxb:schemaBindings>
> <jxb:package name="mypackage"/>
> </jxb:schemaBindings>
> </jxb:bindings>
> </jxb:bindings>
>
> However, it generates a class org.w3._2001.xmlschema.Adapter1.java. I
> would like the file to be mypackage.Adapter1. So I tried:
>
> <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="mydef.xsd" node="/xs:schema">
> <jxb:property>
> <jxb:baseType>
> <jxb:javaType name="java.lang.Integer" xmlType="xs:integer"/>
> </jxb:baseType>
> </jxb:property>
> <jxb:schemaBindings>
> <jxb:package name="mypackage"/>
> </jxb:bindings>
> </jxb:bindings>
>
> but xjc gives an error
>
> [ERROR] cvc-complex-type.3.2.2: Attribute 'xmlType' is not allowed to
> appear in element 'jxb:javaType'.
> line 7 of file:...
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>