小编ole*_*lek的帖子

JAXB选择清单

我有以下架构

<complexType name="BookShelf">
   <sequence>
      <element name="newBook" type="string" minOccurs="0" maxOccurs="unbounded"/>
      <element name="oldBook" type="string" minOccurs="0" maxOccurs="unbounded"/>
   </sequence>
</complexType>
Run Code Online (Sandbox Code Playgroud)

XJC生成带有两个列表的BookShelf类,一个用于newBook,另一个用于oldBook.优秀!

现在我希望书籍以任何顺序出现.所以我将我的架构重写为:

<complexType name="BookShelf">
   <sequence>
      <choice minOccurs="0" maxOccurs="unbounded">
         <element name="newBook" type="string"/>
         <element name="oldBook" type="string"/>
      </choice>
   </sequence>
</complexType>
Run Code Online (Sandbox Code Playgroud)

但是现在XJC生成的BookShelf只有一个类型的newBookOrOldBook列表List<JAXBElement<String>>.

我不关心书籍出现的顺序,我想让XML编写者按照他希望的任何顺序指定书籍,但我仍然希望在生成的BookShelf类中将每种类型的书籍作为List.有什么办法可以实现吗?

xsd jaxb xjc

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

jaxb ×1

xjc ×1

xsd ×1