You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Neil Graham <ne...@ca.ibm.com> on 2003/07/09 23:00:49 UTC

Re: keys, keyrefs, and the default namespace

Hi Joe,

No, all is as it should be.  xpath expressions don't take the default
namespace into account.  (If you hunt through bugzilla a bit you can find a
couple of "bugs" about this, at least one of which will have the
appropriate reference  to the XPath spec in it).

Cheers,
Neil
Neil Graham
XML Parser Development
IBM Toronto Lab
Phone:  905-413-3519, T/L 969-3519
E-mail:  neilg@ca.ibm.com




|---------+---------------------------->
|         |           Joseph Rank      |
|         |           <jrank@austin.rr.|
|         |           com>             |
|         |                            |
|         |           07/09/2003 02:38 |
|         |           PM               |
|         |           Please respond to|
|         |           xerces-j-user    |
|         |                            |
|---------+---------------------------->
  >---------------------------------------------------------------------------------------------------------------------------------------------|
  |                                                                                                                                             |
  |       To:       xerces-j-user@xml.apache.org                                                                                                |
  |       cc:                                                                                                                                   |
  |       Subject:  keys, keyrefs, and the default namespace                                                                                    |
  |                                                                                                                                             |
  |                                                                                                                                             |
  >---------------------------------------------------------------------------------------------------------------------------------------------|




Hello, all.

I'm using Xerces 2.4.0 on Linux and am having no luck getting the SAX
parser to enforce XML Schema identity constraints using the default
namespace.

On the other hand, if I specify an explicit namespace for my schema, and
the XPath expressions in my key and keyref selectors use the qualified
name that includes the prefix, everything works.

So, having defined a document root, a child element of the root, and the
child's children, "thing" and "thingRef", this

<xsd:schema xmlns="http://example.com/schema"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   targetNamespace="http://example.com/schema">

...

   <xsd:key name="thingKey">
     <xsd:selector xpath=".//thing"/>
     <xsd:field xpath="@code"/>
   </xsd:key>

   <xsd:keyref name="thingKeyRef" refer="thingKey">
     <xsd:selector xpath=".//thingRef"/>
     <xsd:field xpath="@id"/>
   </xsd:keyref>

...

</xsd:schema>

doesn't throw any errors when the thingRef ids don't match the thing
codes in an instance document (which was a surprise; I expected an
identity constraint error), but this

<xsd:schema xmlns:pre="http://example.com/schema"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   targetNamespace="http://example.com/schema">

...

   <xsd:key name="thingKey">
     <xsd:selector xpath=".//pre:thing"/>
     <xsd:field xpath="@code"/>
   </xsd:key>

   <xsd:keyref name="thingKeyRef" refer="pre:thingKey">
     <xsd:selector xpath=".//pre:thingRef"/>
     <xsd:field xpath="@id"/>
   </xsd:keyref>

...

</xsd:schema>

does. Shouldn't the case with the default namespace behave the same as
the case with the explicit namespace?

Any insight would be appreciated,

-Joe



#### smime.p7s has been removed from this note on July 09 2003 by Neil
Graham