【发布时间】:2011-11-21 13:33:00
【问题描述】:
我想验证元素“测试”是否应该
- 限制其内容(例如,使用模式限制),并且
- 包含某些属性(例如,“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:attribute”元素上收到以下错误:
“属性”和内容模型互斥
有没有办法验证同一元素上的内容限制和属性?
【问题讨论】:
标签: attributes xsd restriction