JAXB 区分大小写的类生成
我想从标准架构学习对象模型创建类。该架构似乎因小写类型而被破坏。有什么方法可以在“不区分大小写”模式下使用 jaxb 生成类吗?
这是冲突出现的问题:
<xs:complexType name="Duration">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="duration" type="DurationValue"/>
<xs:element name="description" type="description"/>
<xs:group ref="ex:customElements"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="duration">
<xs:complexContent>
<xs:extension base="Duration">
<xs:attributeGroup ref="ag:duration"/>
<xs:attributeGroup ref="ex:customAttributes"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
我已将“duration”标签重命名为“customDuration”,并且我也更改了引用并且它有效。
谢谢你!
I want to create classes from a standard schema learning object model. The schema appears to be broken due to a lowercased type. Is there any way that I can generate classes with jaxb in a "case insensitve" mode?
Here is the problem where the conflict comes out:
<xs:complexType name="Duration">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="duration" type="DurationValue"/>
<xs:element name="description" type="description"/>
<xs:group ref="ex:customElements"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="duration">
<xs:complexContent>
<xs:extension base="Duration">
<xs:attributeGroup ref="ag:duration"/>
<xs:attributeGroup ref="ex:customAttributes"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
I have rename the "duration" tag to "customDuration" and I have change the references as well and it works.
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您应该更改模式以便拥有
Duration
和duration_
,生成 JAXB 对象,然后更改生成的 JAXB 类以使它们适应原始 WSDL。例如,在Java中:(我简化了示例中的类型)。不管怎样,希望你能找到更好的解决方案。
I think that you should change the schema in order to have
Duration
andduration_
, generate JAXB objects and then change your JAXB classes generated in order to adapt them to the origina WSDL. For example, in Java:(I have simplified the types in the example). Hope anyway you find a better solution.
这已经被回答了,但希望这对其他人有帮助,使用 -XautoNameResolution 以便每当遇到两个具有相同名称的元素(不区分大小写)时就会生成新的类。我将其用作以下
xjc -d src -p com.sample -wsdl somewsdl.wsdl -XautoNameResolution
This was already answered but Hope this will help some one else , use -XautoNameResolution so that new classes will be generated whenever it encounters two elements with same name (Case insensitive). I used it as following
xjc -d src -p com.sample -wsdl somewsdl.wsdl -XautoNameResolution