您可以在下面找到 XSD 的一部分:
<xs:element name="MyElement" minOccurs="0" maxOccurs="1">
    <xs:complexType>
        <xs:choice>
            <xs:element maxOccurs="unbounded" name="MyChildElement">
                <xs:complexType>
                    <xs:attribute name="MyAttribute1" type="xs:decimal" use="optional" />
                    <xs:attribute name="MyAttribute2" type="xs:decimal" use="optional" />
                    <xs:attribute name="MyAttribute3" type="xs:decimal" use="optional" />
                </xs:complexType>
            </xs:element>
        </xs:choice>
    </xs:complexType>
</xs:element>
它接受这两种 XML:
<MyElement>
    <MyChildElement MyAttribute1="10" />
    <MyChildElement MyAttribute2="10" />
</MyElement>
<MyElement>
    <MyChildElement MyAttribute1="10" MyAttribute2="10" MyAttribute3="10" />
</MyElement>
我想知道是否有办法强制 XSD 只接受第一个,即每个元素只有一个属性。
谢谢你。