我想验证一个元素“测试”应该
- 限制其内容(例如,使用模式限制),并且
- 包含某些属性(例如,“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”元素上收到以下错误:
“属性”和内容模型是互斥的
有没有办法验证同一元素的内容限制和属性?