如何解决如何生成JAXB POJO,其中包含其他类型的元素的列表
我正在创建这个新元素 DocumentInfoList ,我想包含另一个已经定义的元素DocumentInfo的列表:
<xs:element name="DocumentInfoList">
<xs:complexType>
<xs:sequence>
<xs:element name="DocumentInfo" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
DocumentInfo 已经定义如下:
<xs:element name="DocumentInfo">
<xs:complexType>
<xs:sequence>
<xs:element name="version" type="xs:dateTime"/>
<xs:element name="year" type="type:Year" minOccurs="0"/>
<xs:element name="context" type="xs:string" default="NONE"/>
<xs:element name="format" type="type:FormatType" default="JSON"/>
<xs:element name="document" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
注意,我在DocumentInfoList.DocumentInfo上缺少type属性,因此生成的pojo具有通用对象的类型。
如何使DocumentInfoList包含DocumentInfo元素列表?
我尝试这样做:
<xs:element name="DocumentInfo" type="DocumentInfo" minOccurs="1" maxOccurs="unbounded"/>
但这显然失败了,因为DocumentInfo
是元素而不是类型。我也尝试使用类似的东西:
<xs:element ref="DocumentInfo" minOccurs="1" maxOccurs="unbounded"/>
作为对其他元素的引用,但这似乎并不奏效。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。