Hi Marcel,

     The default namespace in an XML file never applies to attributes. See 
Section 5.2 of the Namespaces in XML Recommendation [1] for more 
information.

     I'm guessing that your input document looks something like the 
following.  In this example, both the elements "BinaryCollaboration" and 
"Role" will be in the namespace identified by the URI http://example.org, 
but the attribute "name" will be in no namespace.

<BinaryCollaboration xmlns="http://example.org";>
  <Role name="friend"/>
</BinaryCollaboration>

     I hope that helps.

Thanks,

Henry
[1] http://www.w3.org/TR/REC-xml-names/#defaulting
------------------------------------------------------------------
Henry Zongaro      Xalan development
IBM SWS Toronto Lab   T/L 969-6044;  Phone +1 905 413-6044
mailto:[EMAIL PROTECTED]




Marcel <[EMAIL PROTECTED]>
2003-08-21 06:42 PM

 
        To:     [EMAIL PROTECTED]
        cc: 
        Subject:        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




Reply via email to