我有一个XSD,其属性为boolean,整数和元素为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>
答案 0 :(得分:1)
使用
<xsd:element name="jsonrecords" minOccurs="0" maxOccurs="unbounded" type="xsd:anySimpleType" />
它会产生类似
的东西@XmlSchemaType(name = "anySimpleType")
protected List<Object> jsonrecords;
答案 1 :(得分:0)
请参阅此处的映射图http://docs.oracle.com/javaee/5/tutorial/doc/bnazq.html,你可以使用应该转换为java.lang.Object的xsd:anySimpleType