JAXB XML任何元素严格的对象创建

时间:2015-06-26 15:03:11

标签: java xml jaxb

XSD:

<xs:complexType name="row">
    <xs:sequence maxOccurs="unbounded">
        <xs:any processContents="skip"/>
    </xs:sequence>
</xs:complexType>

Generated Java:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "row", propOrder = {
    "any"
})
public class ReportRowType {

    @XmlAnyElement
    protected List<Element> any;

    ...
}

如何正确创建XML org.w3c.dom.Element以放入此处?我只是创建一个随机文档?这对我来说似乎不对:

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.newDocument();
Element e = doc.createElement("random_tag_name");
row.getAny().add(e)?

0 个答案:

没有答案