Xmlns attributes are regular attributes. The only thing special about them is that they have an implicitly defined namespace.

-Nathan

Sent from my iPhone

On Apr 7, 2009, at 5:34 PM, Michael Ludwig <mil...@gmx.de> wrote:

Given the following input document:

   <Urmel a="1" b="2" xmlns="urn:x-U" xmlns:v="urn:x-V"/>

And the following code:

   static void showAttributes(Document doc) {
       Node docElm = doc.getDocumentElement();
       NamedNodeMap nodeMap = docElm.getAttributes();
       int len = nodeMap.getLength();
       for (int i = 0; i < len; i++) {
           Attr attr = (Attr) nodeMap.item(i);
           System.out.println(attr.getName() + " " + attr);
       }
   }

Four attributes are shown:

   a a="1"
   b b="2"
   xmlns xmlns="urn:x-U"
   xmlns:v xmlns:v="urn:x-V"

Do namespace declaration attributes count as real attributes in the DOM?

I noticed that contrary to Xerces, LibXML2 does not count namespace
declaration attributes among the real attributes.

Can I make the Xerces parser or the document not include them among the
attributes? (In the XPath Data Model, they're not attributes.)

Or do they filter out the xmlns: attributes by checking the prefix and
the namespace URI when building the XDM from the DOM?

Michael Ludwig

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org
For additional commands, e-mail: j-users-h...@xerces.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org
For additional commands, e-mail: j-users-h...@xerces.apache.org

Reply via email to