【发布时间】:2018-01-30 02:44:27
【问题描述】:
谁能告诉我,是否可以定义一个可以包含多个复杂子类型元素的类型。然而,
- 它必须至少包含一个孩子。
- 对于这个孩子,孙子的值被限制为一个特定的值。
- 对于可选的其他子项,孙子项的值被限制为一组字符串值。
例子:
<Identifiers>
<ns:Identifier xmlns:ns='http://schemas.com/common'>
<ns0:SourceSystem xmlns:ns0='http://schemas.com/common'>ORACLE</ns0:SourceSystem>
<ns0:IDType xmlns:ns0='http://schemas.com/common'>PARTY_ID</ns0:IDType>
<ns0:IDValue xmlns:ns0='http://schemas.com/common'>38784313</ns0:IDValue>
</ns:Identifier>
<ns:Identifier xmlns:ns='http://schemas.com/common'>
<ns0:SourceSystem xmlns:ns0='http://schemas.com/common'>ORACLE</ns0:SourceSystem>
<ns0:IDType xmlns:ns0='http://schemas.com/common'>ANY_ID</ns0:IDType>
<ns0:IDValue xmlns:ns0='http://schemas.com/common'>12345</ns0:IDValue>
</ns:Identifier>
Identifier 元素的第一次出现具有 IDType 的强制值“PARTY_ID”。第二次出现是可选的,可以是枚举中的任何值。
以下是当前 XSD 的一些摘录,其中对 Identifier 元素的数量没有限制。
<xsd:complexType name="IdentifiersType">
<xsd:sequence>
<xsd:element name="Identifier" type="cmn:IdentifierType" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:complexType name="IdentifierType">
<xsd:sequence>
<xsd:element name="SourceSystem"/>
<xsd:element ref="cmn:IDType"/>
<xsd:element name="IDValue" type="xsd:string"/>
</xsd:sequence>
<xsd:simpleType name="IDType">
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
<xsd:enumeration value="VENDOR_ID"/>
<xsd:enumeration value="VENDOR_SITE_ID"/>
<xsd:enumeration value="VENDOR_SITE_NUMBER"/>
<xsd:enumeration value="APPLICANT_ID"/>
<xsd:enumeration value="AGMNT_ID"/>
<xsd:enumeration value="SAMPLE_ID"/>
<xsd:enumeration value="PROGRAM_ID"/>
<xsd:enumeration value="QUOTE_ID"/>
<xsd:enumeration value="AAA_PARTY_ID"/>
...
<xsd:enumeration value="PARTY_ID"/>
</xsd:restriction>
非常感谢任何帮助。
【问题讨论】: