Re: Doubt in Unique Particle Attribution Constraint

On 17 Feb 2009, at 22:29 , Bharath Kumar Reddy T wrote:


 > According to spec. Two non-group particles overlap if

 >    They are both element declaration particles one of
 >    whose {name} and {target namespace} are the same as
 >    those of an element declaration in the other's
 >    ·substitution group·.

I think this is true.

 > In the following schema, element ref = b and element ref =
 > c are both element declarations and c's name and target
 > namespace are same as b's substitution group's name and
 > targetnamespace. So, they both overlap. and both are under
 > <choice> model group. So, the content model is
 > non-deterministic.

I think you are oversimplifying here.  Element 'b' names 'c'
as its substitution group head, but element 'c' is declared
with block="substitution", which means that 'b' is *not* in
the substitution group of 'c'.  The substitution group of
'c' consists, according to the definition of 'substitution
group' in XSD 1.0, of the elements which

   - are c, or name c or any element in c's "potential
     substitution group" as their substitution group head
   - have {abstract} = false
   - are validly substitutable for c subject to c's
     {disallowed substitutions} (i.e. its block attribute)

Element 'b' fails that last test, so it's not substitutable
for element 'c'.  And similarly it's not substitutable for 'd'.

 > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
 >
 >   <xs:element name="a" type="xs:short" substitutionGroup="b"/>
 >   <xs:element name="b" type="xs:decimal" substitutionGroup="c"/>
 >   <xs:element name="c" type="xs:decimal" block="substitution"  
substitutionGroup="d"/>
 >   <xs:element name="d" block="substitution"/>
 >   <xs:element name="foo"/>
 >
 >   <xs:complexType name="base">
 >     <xs:choice>
 >       <xs:element ref="b"/>
 >       <xs:element ref="c"/>
 >       <xs:element ref="d"/>
 >       <xs:element ref="foo"/>
 >     </xs:choice>
 >   </xs:complexType>
 >
 >   <xs:element name="doc" type="base"/>
 >
 > </xs:schema>

If you see

   <doc><b>

at the beginning of a document instance, how many
content-model particles could you be matching?

You could be matching the reference to 'b'.

You cannot be matching the references to 'c' or 'd', since
they both have block="substitution".

You cannot be matching the reference to 'foo', since the
names 'foo' and 'b' differ.

So the particle to which the 'b' element in the instance
must be attributed is uniquely determined.  The content
model thus satisfies, for this case, the Unique Particle
Attribution rule.  (For this case, and in fact for all
cases.)

 > But one of the XML parsers is not giving any error about
 > the non-deterministic content model.

One of the parsers is correct!

 > Please reply me whether the elements <xs:element ref="b"/>
 > and <xs:element ref="c"/> will overlap or not. and whether
 > the content model is non-deterministic or not.

I hope this helps.

-- 
****************************************************************
* C. M. Sperberg-McQueen, Black Mesa Technologies LLC
* http://www.blackmesatech.com
* http://cmsmcq.com/mib
* http://balisage.net
****************************************************************

Received on Thursday, 19 February 2009 00:51:05 UTC