Jaxb 确定派生类中xml混合内容的顺序
我有这样的模式:Jaxb 确定派生类中xml混合内容的顺序,jaxb,xjc,Jaxb,Xjc,我有这样的模式: <xsd:complexType name="ContentType" mixed="true"> <xsd:annotation> <xsd:documentation><![CDATA[ The content type is a broad base type allowing any content. ]]></xsd:documentatio
<xsd:complexType name="ContentType" mixed="true">
<xsd:annotation>
<xsd:documentation><![CDATA[
The content type is a broad base type allowing any content.
]]></xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="BaseContentType">
<xsd:sequence>
<xsd:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="lax"
/>
</xsd:sequence>
<xsd:attribute name="orientation" type="OrientationEnum" use="optional"
default="portrait">
<xsd:annotation>
<xsd:documentation><![CDATA[
The @orientation attribute is used to specify a "landscape"
orientation for the published form. This is primarily used
for schedules or for tables.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
我使用xjc命令行工具从上述模式生成Java类,这些类的生成如下:
public abstract class BaseContentType {
@XmlMixed
protected List<Serializable> content;
@XmlAttribute(name = "id")
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
@XmlID
@XmlSchemaType(name = "ID")
protected String id;
公共抽象类BaseContentType{
@混合
受保护的列表内容;
@xmltattribute(name=“id”)
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
@XmlID
@XmlSchemaType(name=“ID”)
受保护的字符串id;
及
公共类ContentType
扩展BaseContentType
{
@混合
@xmlanyement(lax=true)
@覆盖符号
受保护列表内容OverrideforContentType;
当我解组时,所有嵌套的xml元素被填充到ContentType
对象的列表contentOverrideForContentType
中,所有文本元素被填充到BaseContentType
的列表content
中
如何确定文本元素相对于嵌套元素的顺序并构造整个文本
我正在尝试获取ContentType
中的整个文本,为此我必须查看顶级文本和所有嵌套标记的文本,并将它们全部组合在一起(这里是我需要知道顺序的地方)。是否有更好的方法从ContentType
中提取所有文本
谢谢
编辑
这与问题有关。如果您在特定jaxB类上声明了一个Propoder,那么您可以指定对象在xml中的显示顺序
e.g.
@XmlType(propOrder = {
"firstObjectName",
"fsecondObjectName"
})
注意:使用比例器时,必须将对象中的所有元素添加到比例器。我也有同样的问题,我发现元素将按照元素添加到列表中的顺序进行排序…这是假设您使用的是有序列表(
列表
,数组列表
)
e.g.
@XmlType(propOrder = {
"firstObjectName",
"fsecondObjectName"
})