W3C home > Mailing lists > Public > xmlschema-dev@w3.org > February 2009

Re: Doubt in Unique Particle Attribution Constraint

From: C. M. Sperberg-McQueen <cmsmcq@blackmesatech.com>
Date: Wed, 18 Feb 2009 17:50:26 -0700
Cc: "C. M. Sperberg-McQueen" <cmsmcq@blackmesatech.com>, xmlschema-dev@w3.org, ashutosh_p@huawei.com, ranjit@huawei.com
Message-Id: <33ED4C1F-DAF1-404A-88DD-44FD95FFEC16@blackmesatech.com>
To: Bharath Kumar Reddy T <bharathkr@huawei.com>
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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:15:11 GMT