JAXB 区分大小写的类生成

发布于 2025-01-08 09:11:29 字数 877 浏览 1 评论 0原文

我想从标准架构学习对象模型创建类。该架构似乎因小写类型而被破坏。有什么方法可以在“不区分大小写”模式下使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冷…雨湿花 2025-01-15 09:11:29

我认为您应该更改模式以便拥有 Durationduration_,生成 JAXB 对象,然后更改生成的 JAXB 类以使它们适应原始 WSDL。例如,在Java中:(

@XmlElement(name = "Duration")
protected String duration;

@XmlElement(name = "duration")
protected String duration_;

我简化了示例中的类型)。不管怎样,希望你能找到更好的解决方案。

I think that you should change the schema in order to have Duration and duration_, generate JAXB objects and then change your JAXB classes generated in order to adapt them to the origina WSDL. For example, in Java:

@XmlElement(name = "Duration")
protected String duration;

@XmlElement(name = "duration")
protected String duration_;

(I have simplified the types in the example). Hope anyway you find a better solution.

烟柳画桥 2025-01-15 09:11:29

这已经被回答了,但希望这对其他人有帮助,使用 -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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文