假设我有以下 XSD 文件:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="PACIDemoSignedDoc" type="PACIDemoSignedDocType" />
<xs:complexType name="PACIDemoSignedDocType">
<xs:all>
<xs:element name="OwnerEnglishName" type="OwnerEnglishNameType" />
</xs:all>
</xs:complexType>
<xs:complexType name="OwnerEnglishNameType">
<xs:simpleContent>
<xs:restriction base="NameType">
<xs:enumeration value="John"/>
<xs:enumeration value="Jack"/>
</xs:restriction>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="NameType">
<xs:simpleContent>
<xs:extension base="xs:string"/>
</xs:simpleContent>
</xs:complexType>
</xs:schema>
我的问题是,我应该在哪里为元素 "OwnerEnglishName" 添加属性 minOccurs 和 maxOccurs ?我想保留 xs:all 因为我想避免必须按顺序订购我的 XML 文件,但它禁止我直接<xs:element name="OwnerEnglishName" type="OwnerEnglishNameType" />
在行中添加 Occurs...
我也猜想我不能在 OwnerEnglishNameType 中添加 Occur 属性,有人知道吗?