W3C home > Mailing lists > Public > xmlschema-dev@w3.org > July 2001

Error in Primer? ... xpath expressions in keys

From: Roger L. Costello <costello@mitre.org>
Date: Fri, 13 Jul 2001 14:01:43 -0400
Message-ID: <3B4F3787.55F26DD0@mitre.org>
To: xmlschema-dev@w3.org, costello@mitre.org, mail@jenitennison.com
First, are there any validators which implement identity constraints?  I
have checked the following validators and they do not: xsv 1.2, xerces
1.4.1, and XML Spy 4.0b.

Second, I am beginning to question my understanding of xpath expressions
in <select> or <field> elements.  Here's an example from the Primer that
defines a key (I simplified it a bit):

<schema xmlns="http://www.w3.org/2001/XMLSchema"

   <element name="purchaseReport">
            <element name="parts">
                     <element name="part"> 
      <key name="pNumKey">
         <selector xpath="r:parts/r:part"/>
         <field xpath="@number"/>

Let's examine the xpath expression in the <selector>:

      <selector xpath="r:parts/r:part"/>

This reads as, "select the parts element that is in the
{http://www.example.com/Report} namespace.  From there select the part
child element, which is also in the {http://www.example.com/Report}

Does that sound reasonable?  Well, there's a problem.  Look at the
schema again.  The two elements, parts and part are "local" elements. 
By definition, only global elements are "in the namespace".  So
{http://www.example.com/Report}:parts and
{http://www.example.com/Report}:part do not exist.  Rather, the two
elements are in "no namespace".  

So, how would <selector> identify the desired set of elements?  We
cannot simply remove r: from r:parts and r:part because then we would be
referencing the parts element and the part element in the default
namespace (which in this example is the XMLSchema namespace).  Thus,
these two forms are both incorrect:

        <selector xpath="r:parts/r:part"/>
        <selector xpath="parts/part"/>

I *think* that the way to do it is to declare a namespace prefix and
assign it to no-namespace:


and then qualify parts and part with bitBucket:

 <selector xpath="bitBucket:parts/bitBucket:part"/>

I am on shaky ground here.  I am not at all sure that this is valid.  I
need some clarification please.  Thanks!  /Roger
Received on Friday, 13 July 2001 14:02:25 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:52 UTC