In the DOM, namespace declaration attributes are displayed as real attributes -- but are in fact optional in many cases. See current version of the DOM spec for discussions of Namespace Well-Formedness, Namespace Normalization, and normalization during serialization.
In the XPath data model, namespace declarations are not considered attributes. ______________________________________ "... Three things see no end: A loop with exit code done wrong, A semaphore untested, And the change that comes along. ..." -- "Threes" Rev 1.1 - Duane Elms / Leslie Fish ( http://www.ovff.org/pegasus/songs/threes-rev-11.html) Nathan Beyer <nbe...@gmail.com> 04/07/2009 05:59 PM Please respond to j-users@xerces.apache.org To "j-users@xerces.apache.org" <j-users@xerces.apache.org> cc Subject Re: DOM: Are namespace declaration attributes real attributes? 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