users@jaxb.java.net

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

From: <removeps-groups_at_yahoo.com>
Date: Wed, 7 Jan 2009 20:13:01 -0800 (PST)

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:...