How to write an external binding file for xjc? How to write an external binding file for xjc? xml xml

How to write an external binding file for xjc?


The external binding file is documented on the Customizing JAXB Bindings page on oracle.com

Quote:

External Binding Customization Files

Customizations to JAXB bindings made by means of an external file containing binding declarations take the general form shown below.

<jxb:bindings schemaLocation = "xs:anyURI">   <jxb:bindings node = "xs:string">*      <binding declaration>   <jxb:bindings></jxb:bindings> 

schemaLocation is a URI reference to the remote schema node is an XPath 1.0 expression that identifies the schema node within schemaLocation to which the given binding declaration is associated. For example, the first schemaLocation/node declaration in a JAXB binding declarations file specifies the schema name and the root schema node:

<jxb:bindings schemaLocation="po.xsd" node="/xs:schema"> 

A subsequent schemaLocation/node declaration, say for a simpleType element named ZipCodeType in the above schema, would take the form:

<jxb:bindings node="//xs:simpleType[@name='ZipCodeType']"> 

See also; the JAXB Compiler Options


Another good resource for information on the external binding file is oreilly. An example binding file from oreilly is:

Quote:

Listing 11. Using An External Binding File

<jxb:bindings version="1.0"   xmlns:jxb="http://java.sun.com/xml/ns/jaxb"   xmlns:xs="http://www.w3.org/2001/XMLSchema"   xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"   jxb:extensionBindingPrefixes="xjc">    <jxb:bindings schemaLocation="po4.xsd" node="/xs:schema">        <jxb:globalBindings>            <xjc:superClass name="com.syh.Shape"/>            <xjc:serializable uid="12343"/>        </jxb:globalBindings>        <jxb:bindings node="//xs:element[@name='Widgets']//xs:complexType//xs:choice">            <jxb:property name="Shapes"/>        </jxb:bindings>    </jxb:bindings></jxb:bindings>