我并不擅长创建XSD模式,因为这实际上是我的第一个模式,
我想验证一个XML,它必须如下所示:
<?xml version="1.0"?>
<Data>
<FIELD name='toto'>
<META mono='false' dynamic='false'>
<COLUMN1>
<REFTABLE>table</REFTABLE>
<REFCOLUMN>key_column</REFCOLUMN>
<REFLABELCOLUMN>test_column</REFLABELCOLUMN>
</COLUMN1>
<COLUMN2>
<REFTABLE>table</REFTABLE>
<REFCOLUMN>key_column</REFCOLUMN>
<REFLABELCOLUMN>test_column</REFLABELCOLUMN>
</COLUMN2>
</META>
<VALUEs>
<VALUE>...</VALUE>
</VALUEs>
</FIELD>
我的问题是,进入元块的标签“column1”、“column2”总是不同的,它可能会变成columnxxx。目前我的模式是:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="Data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="FIELD" type="Field" />
</xsd:sequence>
<xsd:attribute name="id" type="xsd:int" use="required" />
</xsd:complexType>
</xsd:element>
<xsd:complexType name="dataSourceDef">
<xsd:sequence>
<xsd:element name="DSD_REFTABLE" type="xsd:string" />
<xsd:element name="DSD_REFCOLUMN" type="xsd:string" />
<xsd:element name="DSD_REFLABELCOLUMN" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="MetaTag">
<xsd:sequence>
<xsd:any processContents="lax" />
</xsd:sequence>
<xsd:attribute name="mono" type="xsd:string" use="required" />
<xsd:attribute name="dynamic" type="xsd:string" use="required"/>
</xsd:complexType>
<xsd:complexType name="Field">
<xsd:sequence>
<xsd:element name="META" type="MetaTag" minOccurs="1" />
<xsd:element name="VALUEs">
<xsd:complexType>
<xsd:sequence>
<xsd:any processContents="lax" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required"/>
</xsd:complexType>
</xsd:schema>
我就是不能让它工作,我不知道如何处理这样一个事实:我的节点的精确级别不清楚,其余的都不清楚。
你能帮我吗?