Note that there are some explanatory texts on larger screens.

plurals
  1. POHaving XML validation issues depending on the XML Parser used.....how do I represent the constraint to be universally accepted
    text
    copied!<p>I have a strange situation that has me perplexed a bit....</p> <p>I have an XML data file I am trying to validate against a schema that seems to give different results depending on the parsers used. Not sure what I am doing wrong or how to better represent the constraints in the schema so that all the parsers can properly validate the XML.... Here is a snippet of the problem portion of the Schema:</p> <pre><code>&lt;xsd:element name="DemoValues"&gt; &lt;xsd:annotation&gt; &lt;xsd:documentation&gt;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. &lt;/xsd:documentation&gt; &lt;/xsd:annotation&gt; &lt;xsd:complexType&gt; &lt;xsd:sequence&gt; &lt;xsd:element name="DemoValue" type="gap:demoValueType" maxOccurs="unbounded"/&gt; &lt;/xsd:sequence&gt; &lt;/xsd:complexType&gt; &lt;xsd:unique name="DemoValueConstraint"&gt; &lt;xsd:annotation&gt; &lt;xsd:documentation&gt;Constraint allows only up to one demo value for a demo category, and per market when a market reference exists. &lt;/xsd:documentation&gt; &lt;/xsd:annotation&gt; &lt;xsd:selector xpath="gap:DemoValue"/&gt; &lt;xsd:field xpath="@demoRef"/&gt; &lt;xsd:field xpath="@marketRef|@demoRef"/&gt; &lt;/xsd:unique&gt; </code></pre> <p></p> <p>Here is the offending XML:</p> <pre><code>&lt;DemoValues&gt; &lt;DemoValue demoRef="DM0" marketRef="MKT1"&gt;0.40&lt;/DemoValue&gt; &lt;DemoValue demoRef="DM1"&gt;15.00&lt;/DemoValue&gt; &lt;/DemoValues&gt; </code></pre> <p>Produces this error:</p> <p>Element '{http://www.AAAA.org/schemas/canadianTVGAP}DemoValue', attribute 'marketRef': The XPath '@marketRef|@demoRef' of a field of unique identity-constraint '{http://www.AAAA.org/schemas/canadianTVGAP}DemoValueConstraint' evaluates to a node-set with more than one member.</p> <p>Simplified Error is: The field ‘marketRef’ is expecting at the most one value.</p> <p>The intent for the xml is to allow all these combinations:</p> <p>1)</p> <pre><code> &lt;DemoValues&gt; &lt;DemoValue demoRef="DM0" marketRef="MKT1"&gt;0.40&lt;/DemoValue&gt; &lt;DemoValue demoRef="DM1"&gt;15.00&lt;/DemoValue&gt; &lt;/DemoValues&gt; </code></pre> <p>2)</p> <pre><code>&lt;DemoValues&gt; &lt;DemoValue demoRef="DM0" marketRef="MKT1"&gt;0.40&lt;/DemoValue&gt; &lt;DemoValue demoRef="DM0" marketRef="MKT2"&gt;0.41&lt;/DemoValue&gt; &lt;DemoValue demoRef="DM0" marketRef="MKT3"&gt;0.42&lt;/DemoValue&gt; &lt;DemoValue demoRef="DM0" marketRef="MKT4"&gt;0.43&lt;/DemoValue&gt; &lt;DemoValue demoRef="DM1"&gt;15.00&lt;/DemoValue&gt; &lt;/DemoValues&gt; </code></pre> <p>3)</p> <pre><code>&lt;DemoValues&gt; &lt;DemoValue demoRef="DM0" marketRef="MKT1"&gt;0.40&lt;/DemoValue&gt; &lt;DemoValue demoRef="DM1" marketRef="MKT1"&gt;0.41&lt;/DemoValue&gt; &lt;DemoValue demoRef="DM2" marketRef="MKT1"&gt;0.42&lt;/DemoValue&gt; &lt;DemoValue demoRef="DM3"&gt;15.00&lt;/DemoValue&gt; &lt;/DemoValues&gt; </code></pre> <p>Thanks for any help!!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload