少し当惑する奇妙な状況があります....
使用するパーサーによって結果が異なるように見えるスキーマに対して検証しようとしている XML データ ファイルがあります。すべてのパーサーが XML を適切に検証できるように、私が何を間違っているのか、またはスキーマ内の制約をより適切に表現する方法がわからない..スキーマの問題部分のスニペットを次に示します。
<xsd:element name="DemoValues">
<xsd:annotation>
<xsd:documentation>Demo values for any, or all, of the demo categories defined on the GAP . A
demo value includes a reference to the category it applies to, a value in the appropriate
format and an optional market reference if it is for a specific market. If the market
reference is omitted the demo value applies to the entire area serviced by the outlet. Each
demo category may only have a single demo value within this group of demo values. However if
the demo value is for a market, there may be a demo value per market within this group of
demo values. </xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="DemoValue" type="gap:demoValueType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:unique name="DemoValueConstraint">
<xsd:annotation>
<xsd:documentation>Constraint allows only up to one demo value for a demo category, and per
market when a market reference exists. </xsd:documentation>
</xsd:annotation>
<xsd:selector xpath="gap:DemoValue"/>
<xsd:field xpath="@demoRef"/>
<xsd:field xpath="@marketRef|@demoRef"/>
</xsd:unique>
問題のある XML は次のとおりです。
<DemoValues>
<DemoValue demoRef="DM0" marketRef="MKT1">0.40</DemoValue>
<DemoValue demoRef="DM1">15.00</DemoValue>
</DemoValues>
次のエラーが発生します。
要素 '{http://www.AAAA.org/schemas/canadianTVGAP}DemoValue'、属性 'marketRef': 一意の同一性制約 '{http://www. AAAA.org/schemas/canadianTVGAP}DemoValueConstraint' は、複数のメンバーを持つノード セットに評価されます。
簡略化されたエラー: フィールド 'marketRef' は最大で 1 つの値を期待しています。
xml の目的は、次のすべての組み合わせを許可することです。
1)
<DemoValues>
<DemoValue demoRef="DM0" marketRef="MKT1">0.40</DemoValue>
<DemoValue demoRef="DM1">15.00</DemoValue>
</DemoValues>
2)
<DemoValues>
<DemoValue demoRef="DM0" marketRef="MKT1">0.40</DemoValue>
<DemoValue demoRef="DM0" marketRef="MKT2">0.41</DemoValue>
<DemoValue demoRef="DM0" marketRef="MKT3">0.42</DemoValue>
<DemoValue demoRef="DM0" marketRef="MKT4">0.43</DemoValue>
<DemoValue demoRef="DM1">15.00</DemoValue>
</DemoValues>
3)
<DemoValues>
<DemoValue demoRef="DM0" marketRef="MKT1">0.40</DemoValue>
<DemoValue demoRef="DM1" marketRef="MKT1">0.41</DemoValue>
<DemoValue demoRef="DM2" marketRef="MKT1">0.42</DemoValue>
<DemoValue demoRef="DM3">15.00</DemoValue>
</DemoValues>
助けてくれてありがとう!!