gpt4 book ai didi

JAXB 自定义绑定(bind) - 从模式中跳过生成的类

转载 作者:行者123 更新时间:2023-12-01 05:10:53 25 4
gpt4 key购买 nike

我有以下架构:

<xs:element name="Invoice">
<xs:complexType>
<xs:sequence>
.....
<xs:element name="InvoiceLines" type="InvoiceLinesType">
</xs:element>
.....
</xs:complexType>
</xs:element>

<xs:complexType name="InvoiceLinesType">
<xs:sequence>
<xs:element maxOccurs="unbounded" name="InvoiceLine" type="InvoiceLineType">
</xs:element>
</xs:sequence>
</xs:complexType>

<xs:complexType name="InvoiceLineType">
<xs:sequence>
.....
</xs:sequence>
</xs:complexType>

问题是,它生成类:

  • Invoice - 包含 InvoiceLinesType 的成员
  • InvoiceLinesType - 包含 InvoiceLineType 的集合
  • 发票行类型

所以有一个不必要的类(InvoiceLinesType),我更喜欢下面的类

  • Invoice - 包含 InvoiceLineType 的集合
  • 发票行类型

有谁知道如何告诉编译器不要生成这个包(InvoiceLinesType)。

我当前的外部绑定(bind)文件在那里

<jxb:bindings schemaLocation="invoice.xsd" node="/xs:schema"> 
<jxb:globalBindings>
.....
<xjc:simple/>
.....
</jxb:globalBindings>
</jxb:bindings>

感谢您的回复。

最佳答案

您将不得不修改您的架构 - 删除 InvoiceLinesType 并将 InvoiceLineType 作为 Invoice 中的无界元素。

<xs:element name="Invoice">
<xs:complexType>
<xs:sequence>
.....
<xs:element maxOccurs="unbounded" name="InvoiceLine" type="InvoiceLineType">
</xs:element>
.....
</xs:complexType>
</xs:element>

<xs:complexType name="InvoiceLineType">
<xs:sequence>
.....
</xs:sequence>
</xs:complexType>

关于JAXB 自定义绑定(bind) - 从模式中跳过生成的类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8988230/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com