xml - Unique Particle Attribution Error with <any>, <element>, and <choice> -


goal:

element octave can have either subnode query or any subnode in namespace http://www.website.com/main.

i don't know where/how violating unique particle attribution...there's no other element called octave or subnode called query. query not global element, used octave.

error:

"cos-nonambig: "http://www.website.com/main":query , wc["http://www.website.com/main"] (or elements substitution group) violate "unique particle attribution". during validation against schema, ambiguity created 2 particles."

schema:

<?xml version="1.0" encoding="utf-8"?>  <xs:schema     xmlns="http://www.website.com/main"     xmlns:xs="http://www.w3.org/2001/xmlschema"      targetnamespace="http://www.website.com/main"      attributeformdefault="unqualified" elementformdefault="qualified"     >  <xs:complextype name="octave" >     <xs:choice>         <xs:element name="query" type="xs:string" />         <xs:any minoccurs="0" maxoccurs="unbounded" namespace="http://www.website.com/main" processcontents="strict" />     </xs:choice>     <xs:attribute name="id" type="xs:string" use="optional" /> </xs:complextype>  <xs:element name="octave" type="octave" /> 

the behavior describe can obtained declaring 'octave' way:

<xs:complextype name="octave" >   <xs:choice>     <xs:any minoccurs="0"              maxoccurs="unbounded"              namespace="http://www.website.com/main"              processcontents="strict" />   </xs:choice>   <xs:attribute name="id"                  type="xs:string"                  use="optional" /> </xs:complextype> 

and declaring query global element:

<xs:element name="query" type="xs:string" /> 

since query element defining in namespace http://www.website.com/main, accepted wildcard , there no pressing need, point of view of 'octave' type, include element reference in choice.

this design have disadvantage of making 'query' accessible existing wildcards match arbitrary elements in namespace http://www.website.com/main. if matters great deal 'query' should appear child of element 'octave' , other elements of same type, might consider making local 'query' element unqualified:

<xs:complextype name="octave" >   <xs:choice>     <xs:element name="query"                  type="xs:string"                  form="unqualified"/>     <xs:any minoccurs="0"              maxoccurs="unbounded"              namespace="http://www.website.com/main"              processcontents="strict" />   </xs:choice>   <xs:attribute name="id"                  type="xs:string"                  use="optional" /> </xs:complextype> 

since declaration of 'query' no longer generates element declaration expanded name in 'main' namespace, no longer competes wildcard.

you might move xsd 1.1, relaxes 'unique particle attribution' rule saying element declarations , references matched in preference wildcards , makes existing declaration legal.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -