我有一个XSD,其属性为boolean,integers和element作为如下的arraylist,

            <?xml version="1.0" encoding="UTF-8"?>
            <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:tns="http://www.template.com/project/v1/Repository"
            targetNamespace="http://www.template.com/project/v1/Repository"
            elementFormDefault="qualified"
            attributeFormDefault="unqualified"
            version="1.0"
            xml:lang="en">

            <xsd:complexType name="Response">
            <xsd:sequence>
                <xsd:element name="records" minOccurs="0" maxOccurs="unbounded" type="tns:Record" />
            </xsd:sequence>
                <xsd:attribute name="pageSize"              type="xsd:integer"   default="-1" />
                <xsd:attribute name="pageNumber"            type="xsd:integer"   default="1" />
            </xsd:complexType>

            <xsd:complexType name="Record">
            <xsd:sequence>
                <xsd:element name="column" minOccurs="0" maxOccurs="unbounded"  type="tns:Column" />
            </xsd:sequence>
            </xsd:complexType>

            <xsd:complexType name="Column">
            <xsd:attribute name="columnId" type="xsd:string" />
            <xsd:attribute name="columnValue" type="xsd:string" />
            </xsd:complexType>


现在正在尝试添加带有对象列表(List<Object>)的元素。我不能在类型中添加Object类。因此,如何在XSD中添加Object类。

            <xsd:element name="jsonrecords" minOccurs="0" maxOccurs="unbounded" type=" "  </xsd:element>

最佳答案

采用

<xsd:element name="jsonrecords" minOccurs="0" maxOccurs="unbounded" type="xsd:anySimpleType" />


它会产生类似

@XmlSchemaType(name = "anySimpleType")
protected List<Object> jsonrecords;

关于java - 在XSD模式下编写java.lang.Object,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27917285/

10-12 00:30
查看更多