我有一个来自第三方提供商的模式声明如下。
<xs:complexType name="GroupParameterType">
<xs:sequence minOccurs="0" maxOccurs="4">
<xs:element name="name" type="xs:string">
<xs:annotation>
<xs:documentation>The name of the parameter.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="value" type="xs:string">
<xs:annotation>
<xs:documentation>The value of the parameter.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
以上是我无法更改的架构。我正在尝试为 jaxb 2.0 编写自定义绑定,以便我可以在 java 代码中将名称称为 GroupParameterType.Name 或 GroupParameterType.Value。
当前的默认绑定为我生成列表,即 getNameandValueList,但我希望分别为名称和值分别设置获取器和设置器。
我尝试放入如下自定义绑定:
<jxb:bindings schemaLocation="GroupParameter.xsd" node="xs:element[@name='name']">
<jxb:globalBindings localScoping="toplevel" generateIsSetMethod="true"/>
</jxb:bindings>
<jxb:bindings schemaLocation="GroupParameter.xsd" node="xs:element[@name='value']">
<jxb:globalBindings localScoping="toplevel" generateIsSetMethod="true"/>
</jxb:bindings>
它没有改变默认的类生成。谁能给我一些指示,那么我接下来还能尝试什么?我希望生成默认的列表以及名称和值的 getter/setter,或者将名称和值作为内部类。如果我删除 maxOccurs=4 选项,我可以生成 getter/setter,但由于我无法修改架构,我正在尝试使用外部绑定文件来获得该行为。
谢谢肖恩