我是否可以将XJC编译器配置为使用自定义XML绑定进行内联自定义? [英] Can I configure XJC compiler to consume custom XML bindings for inline customization?
问题描述
对于JAXB,我们可以使用内联自定义以某种方式调整模式编译器。这可以通过Schema Binding Declarations(< jxb:schemaBindings />)来完成。
For JAXB we could use Inline Customization to adjust schema compiler in some way. This could be done via Schema Binding Declarations (<jxb:schemaBindings/>).
任何制作其他XML标签的方法(例如下面的例子中的ActualType,EnumerationValue)使用标准XJC编译器来影响生成的类?
Any way to make other XML tags (e.g. ActualType, EnumerationValue in example below) work with standard XJC compiler to affect generated classes?
<xs:simpleType name="SomeType">
<xs:annotation>
<xs:appinfo>
<ActualType Name="unsignedInt" />
</xs:appinfo>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:enumeration value="PredefinedEnumValue">
<xs:annotation>
<xs:appinfo>
<EnumerationValue>10000</EnumerationValue>
</xs:appinfo>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
推荐答案
对于枚举值,您需要使用< jaxb:typesafeEnumMember value =10000/>
(查看示例这里)对于简单类型转换,您需要使用< jaxb:baseType name =int />
(查看示例那里)。
For enumeration value you need to use <jaxb:typesafeEnumMember value="10000" />
(check example here) and for simple type conversion you need to use <jaxb:baseType name="int" />
(check example there).
PS Java不支持无符号整数。另外不要忘记在 xmlns:jaxb =http://java.sun.com/xml/ns/jaxb
>< xsd:schema> 。
P.S. Java does not support unsigned ints. Also don't forget to define jaxb namespace xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
in your <xsd:schema>
.
这篇关于我是否可以将XJC编译器配置为使用自定义XML绑定进行内联自定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!