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 Torkel Dominique <to...@hotsip.com> on 2001/02/26 11:49:15 UTC

Schema validation with no namespace

Hi,

I'm trying to apply an xpath string (using the xpath package in Xalan 2.0.0)
to a DOM tree, which is obtained by parsing an XML file with Xerces 1.3.0.
When schema validation is turned off, it works perfectly, but when I parse
with schema validation turned on, the xpath string doesn't match. I'm using
the "xsi:noNamespaceSchemaLocation" attribute to locate the schema, which
(as I was hoping) would set the namespaceURI (obtained by getNamespaceURI()
in DOM) to null. It turned out that the namespaceURI is set to an empty
string (""), which makes the xpath execution fail. When schema validation is
turned off the namespaceURI is set to null.

This is how my XML document looks:

<?xml version='1.0'?>
<userProfile xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"

xsi:noNamespaceSchemaLocation="http://www.hotsip.com/pmi/schema/userProfile"
>
 <services>
  <service>
   <serviceName>service1</serviceName>
   <inmethods>method1</inmethods>
   <outmethods>method2</outmethods>
   <priority>10</priority>
  </service>
 </services>
</userProfile>

And this is my xpath string:

"userProfile/services/service"

Now, is this a xerces problem or a xalan problem?
Shouldn't it be possible to match an element with no namespace using the
same xpath string as the same element when not using validation? (i.e.
without namespace prefix)
Does any one know how to fix this problem?
(I need validation, but I dont want to use namespace prefix in the xpath.)

Thanks,

Torkel Dominique