While debugging some code this weekend, I had occasion to step through the bowels of Apache AXIS and came face to face with something that looked suspicious:new QName(null,...)It turns out that SAX, DOM, and javax.xml.namespace.QName all treat unspecified namespaces differently.
SAX
In SAX, null URIs are not permitted and an absent URI is communicated as the the empty string (""):uri - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
DOM
In DOM, on the other hand, null URIs are the required representation for an unspecified namespace:Applications should use the value null as the namespaceURI parameter for methods if they wish to have no namespace. In programming languages where empty strings can be differentiated from null, empty strings, when given as a namespace URI, are converted to null. This is true even though the DOM does no lexical checking of URIs.(Namespaces in DOM are a train wreck anyway.)
java.xml.namespace.QName
Even though it's incompatible with both DOM and SAX, it turns out that according to J2EE 1.4 passing a null URI is OK for javax.xml.namespace.QName:If the Namespace URI is null, it is set to "". This value represents no explicitly defined Namespace as defined by the Namespaces in XML specification. This action preserves compatible behavior with QName 1.0.If the local part is null, an java.lang.IllegalArgumentException is thrown.If the prefix is null, an java.lang.IllegalArgumentException is thrown. Use "" to explicitly indicate that no prefix is present or the prefix is not relevant.