我有以下XSD,我从...生成JAXB绑定(仅留下此问题的相关部分):
<?xml version="1.0"?>
<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:simplify="http://jaxb2-commons.dev.java.net/basic/simplify"
jaxb:extensionBindingPrefixes="simplify">...
<xsd:element name="trace">
<xsd:annotation>
<xsd:documentation>
containing screen navigation data
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:choice minOccurs ="0" maxOccurs ="unbounded">
<xsd:element ref="time" />
<xsd:element ref="event" />
<xsd:element ref="location" />
<xsd:element minOccurs="0" ref="index" ></xsd:element>
<xsd:element minOccurs="0" ref="caseId"/>
<xsd:element minOccurs="0" ref="contactAttId" />
<xsd:element minOccurs="0" ref="action" />
</xsd:choice>
</xsd:complexType>
</xsd:element>
答案 0 :(得分:1)
您可以使用以下架构
<xsd:simpleType name="LayerRate_T">
<xsd:annotation>
<xsd:appinfo>
<xjc:javaType name="org.acme.foo.LayerRate" adapter="org.acme.foo.LayerRateAdapter" />
</xsd:appinfo>
</xsd:annotation>
</xsd:simpleType>
当包含绑定配置到您的XSD时,相反,当您使用外部绑定时是不同的。
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:simplify="http://jaxb2-commons.dev.java.net/basic/simplify"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:extensionBindingPrefixes="xjc simplify" jaxb:version="2.1">
<jaxb:bindings schemaLocation="compass_input_spec_12122014.xsd" node="/xsd:schema">
<jaxb:bindings node="//xsd:element[@name='trace']/xsd:complexType">
<simplify:property name="timeOrEventOrLocation">
<simplify:as-element-property />
</simplify:property>
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>