JAXB List Tag creating inner class(JAXB List Tag 创建内部类)
问题描述
所以我们在表单中有一个 XSD 类型:
So we have an XSD type in the form:
<xs:complexType name="Foo">
<xs:all>
<xs:element name="Bars">
<xs:complexType>
<xs:sequence>
<xs:element name="Bar" type="barType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
表示 XML:
<Foo>
<!-- Elements snipped for brevity-->
<Bars>
<Bar>
<!-- Bar Element -->
</Bar>
</Bars>
</Foo>
xjc 产生几乎正确的结果.唯一令人讨厌的是Bars"被创建为一个存储 Bars 列表的内部类.有没有办法让 Bars 成为 Foo 中的一个列表,同时仍然保留上面的 XML?
xjc produces almost correct results. The only annoying thing is that "Bars" is created as an inner class which stores a list of Bars. Is there anyway to have Bars be a List in Foo while still retaining the XML above?
推荐答案
另一种方法是去掉周围的<bars>元素,XML 看起来不再那么漂亮了,但它会使 java 代码更易于阅读.连同 xjc 的简单绑定(参见 http://jaxb.java.net/nonav/jaxb20-fcs/docs/vendorCustomizations.html) 它将生成非常漂亮和有用的 java 代码.
Another way would be to drop the surrounding <bars> element, the XML does not look so nice anymore, but it would make the java code easier to read. Together with xjc's simple binding (see http://jaxb.java.net/nonav/jaxb20-fcs/docs/vendorCustomizations.html) it will produce quite pretty and usefull java code.
这篇关于JAXB List Tag 创建内部类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:JAXB List Tag 创建内部类
基础教程推荐
- Struts2 URL 无法访问 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
