次の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スキーマを組み合わせて検証しました。私の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つの値を期待しています。行:1列:271 **
ここで言及する価値があるのは、2番目の要素の値を変更しても、このエラーメッセージが表示されることです。それは最も厄介です.....
私はそれが問題のあるオンライン検証ツールではないと確信しています。Stackoverflowで見つけた次の例では非常にうまく機能します。
XMLスキーマで検証されたドキュメントで一意の値を確保する方法
この全体の問題は私を精神的に駆り立てています。私は何時間もかけてさまざまな構文を試しましたが、無駄になりました。上記のエラーメッセージは、スキーマで実際に独自の作業を行うことができる限り近いものです。
誰かアイデアはありますか……?