[Home] [By Thread] [By Date] [Recent Entries]
I have been trying to understand the reasons why default namepaces do not apply to attributes but only elements. Section 5.2 of Namespaces in XML (http://www.w3.org/TR/1999/REC-xml-names-19990114/) states: A default namespace is considered to apply to the element where it is declared (if that element has no namespace prefix), and to all elements with no prefix within the content of that element. <snip> Note that default namespaces do not apply directly to attributes. I find this very cumbersome when writing XML documents that use namespaces. For example, I cannot do the following: <document xmlns="mynamespace"> <element attribute1="2" attribute4="test"> </element> </document> I am forced to do this: <document xmlns="mynamespace" xmlns:explicit="mynamespace"> <element explicit:attribute1="2" explicit:attribute4="test"> </element> </document> Surely attributes more often than not will belong to the same namespace as their element? Regards, Lisa
|

Cart



