Error in Primer? ... xpath expressions in keys

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"
        targetNamespace="http://www.example.com/Report"
        xmlns:r="http://www.example.com/Report"
        ...>

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

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}
namespace."

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:

   xmlns:bitBucket=""

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