You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Marcel <cr...@gmx.de> on 2003/08/22 00:42:54 UTC
XPath default namespace in attributes
Hi,
I have a problem with the default namespace and an xpath query.
I know I have to set the namespace declaration as described in the faq.
This works great for nodes, but unfortunately not for attributes.
The following xpath query fails on the xml file:
/ox:BinaryCollaboration/ox:Role/@ox:name
but this one is successful:
/ox:BinaryCollaboration/ox:Role/@name
I use the selectNodeList() method and add the namespace in the third
parameter.
My problem is that the xml file sometimes has a default namespace, and
sometimes not.
Do you know how I can set the default namespace for the attributes? Or
do you have another solution for my problem ?
Any help is apprectiated.
Marcel
Re: XPath default namespace in attributes
Posted by Joseph Kesselman <ke...@us.ibm.com>.
>My problem is that the xml file sometimes has a default namespace, and
>sometimes not.
XPath is namespace aware. It doesn't care how the namespace is expressed;
whether prefix or default, it's matching on the namespace and local name,
not the QName.
XPath 1.0 does not support default namespaces in XPath expressions. You
must use a prefix to denote the desired namespace, even when the document
being searched didn't.
XPath 2.0 has proposed changing this. But 2.0 is still only a Working
Draft.
______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more.
"The world changed profoundly and unpredictably the day Tim Berners Lee
got bitten by a radioactive spider." -- Rafe Culpin, in r.m.filk