外部绑定文件记录在 oracle.com 上的自定义 JAXB 绑定页面上
引用:
外部绑定自定义文件
通过包含绑定声明的外部文件对 JAXB 绑定进行的定制采用如下所示的一般形式。
<jxb:bindings schemaLocation = "xs:anyURI">
<jxb:bindings node = "xs:string">*
<binding declaration>
<jxb:bindings>
</jxb:bindings>
schemaLocation 是对远程模式节点的 URI 引用,是一个 XPath 1.0 表达式,用于标识与给定绑定声明关联的 schemaLocation 中的模式节点。例如,JAXB 绑定声明文件中的第一个 schemaLocation/node 声明指定了模式名称和根模式节点:
<jxb:bindings schemaLocation="po.xsd" node="/xs:schema">
随后的 schemaLocation/node 声明,例如上述模式中名为 ZipCodeType 的 simpleType 元素,将采用以下形式:
<jxb:bindings node="//xs:simpleType[@name='ZipCodeType']">
也可以看看; JAXB 编译器选项
关于外部绑定文件信息的另一个好资源是oreilly。来自oreilly的示例绑定文件是:
引用:
清单 11. 使用外部绑定文件
<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>