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 Joseph Rank <jr...@austin.rr.com> on 2003/07/09 20:38:07 UTC
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