8
在相同的元素的属性的验证我想验证的元素“测试”应内容限制和XSD
- 具有其含量受限制的(例如,使用图案限制),和
- 包含某些属性(例如,'id','class'和'name')。
的XSD我在写这个样子的:
<xsd:element name="Test" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType mixed="true">
<xsd:simpleContent>
<xsd:restriction>
<xsd:pattern value="xyz"/>
</xsd:restriction>
</xsd:simpleContent>
<xsd:attribute name="id" type="xsd:string"></xsd:attribute>
<xsd:attribute name="class" type="xsd:string"></xsd:attribute>
<xsd:attribute name="name" type="xsd:string"></xsd:attribute>
</xsd:complexType>
</xsd:element>
然而,当我在Visual Studio代码,我得到了以下错误的 '的xsd:属性' 元素:
“属性”和内容模型是相互排斥的
有没有办法来验证这两个内容限制和属性在同一个元素上?
谢谢!这工作完美。这也很方便,因为我想在其他地方重新使用限制。顺便说一句 - 我有多行内容的问题,但通过在模式后面添加' xsd:whiteSpace>'来解决这些问题。 –
Jonathan