我有以下 XML 文档:
<?xml version="1.0"?>
<BillingRunParameters>
<BusinessUnit BillFullBusinessUnit="false">XXXXXXXX</BusinessUnit>
<Portal BillFullPortal="false">XXXXXXX</Portal>
<BillingTargets>
<CustomerIdList CustomerBilling="true">
<CustomerId>1234567891</CustomerId>
<CustomerId>1234567891</CustomerId>
</CustomerIdList>
<TransactionIdList TransactionBilling="true" ApplicationTransactions="true">
<TransactionId>12345ABC</TransactionId>
<TransactionId>1232K89C</TransactionId>
</TransactionIdList>
</BillingTargets>
</BillingRunParameters>
我将以下 XML Schema 放在一起进行验证。我的 XSD 包含对 CustomerId 元素的唯一约束。可以存在多个 CustomerId 元素,但不能有多个包含相同值的元素(如上所示)。
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" version="1.0" xdb:storeVarrayAsTable = "true">
<xs:element name="BillingRunParameters" xdb:defaultTable="XSD_BILLING_PARAMETERS">
<xs:complexType>
<xs:sequence>
<xs:element name="BusinessUnit" type="typeBusinessUnit" minOccurs="1" maxOccurs="1"/>
<xs:element name="Portal" type="typePortal" minOccurs="1" maxOccurs="1"/>
<xs:element name="BillingTargets" type="typeBillingTargets" minOccurs="0" maxOccurs="1" xdb:defaultTable="XSD_BILLING_TARGETS"/>
</xs:sequence>
</xs:complexType>
<xs:unique name="testCustomerIdUnique">
<xs:selector xpath="BillingTargets/CustomerIdList"/>
<xs:field xpath="CustomerId"/>
</xs:unique>
</xs:element>
<xs:simpleType name="valiatorBusinessUnit">
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="30"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="typeBusinessUnit">
<xs:simpleContent>
<xs:extension base="valiatorBusinessUnit">
<xs:attribute name="BillFullBusinessUnit" type="xs:boolean" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType >
<xs:simpleType name="valiatorPortal">
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="30"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="typePortal">
<xs:simpleContent>
<xs:extension base="valiatorPortal">
<xs:attribute name="BillFullPortal" type="xs:boolean" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="typeBillingTargets">
<xs:sequence>
<xs:element name="CustomerIdList" type="typeCustomerIdList" minOccurs="1" maxOccurs="1"/>
<xs:element name="TransactionIdList" type="typeTransactionIdList" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="typeCustomerIdList">
<xs:sequence>
<xs:element name="CustomerId" type="typeCustomerId" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="CustomerBilling" type="xs:boolean" use="required"/>
</xs:complexType>
<xs:simpleType name="typeCustomerId">
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="20"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="typeTransactionIdList">
<xs:sequence>
<xs:element name="TransactionId" type="typeTransactionId" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="TransactionBilling" type="xs:boolean" use="required"/>
<xs:attribute name="ApplicationTransactions" type="xs:boolean" use="required"/>
</xs:complexType>
<xs:simpleType name="typeTransactionId">
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="20"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
我正在使用以下在线验证工具:
不幸的是,所有唯一约束指令似乎都将我限制为单个 CustomerId 元素。我收到以下错误消息:
**“CustomerId”字段最多需要一个值。行:1 列:271 **
这里值得一提的是,如果我更改第二个元素的值,我仍然会收到此错误消息。最让人头疼的是......
我很确定这不是在线验证工具的问题。它适用于我在 Stackoverflow 上找到的以下示例:
这整个问题都在驱使我思考。我花了几个小时尝试各种语法都无济于事。上面的错误消息与我在我的架构中实际有独特的工作一样接近.....
有没有人有任何想法......?