I have noticed that certain misconceptions in using XML seem to come up over and over again, often with the result that some piece of software claims to support XML, but in reality it has certain idiosyncrasies that harm interoperability. The most egregious of these issues revolve around the use of namespaces and namespace prefixes. It’s not just novice developers, either; recently I was reading the developer documentation for Facebook Chat (to confirm my impression that it had an XMPP interface) when I came across the following: “The XML parser does not yet fully handle XML namespaces. Please stick to the same style as the examples in XMPP RFCs 3920 and 3921 when using XML namespaces.” Similarly, I was warned by the W3C Feed Validation Service when I submitted an Atom feed which used namespace prefixes for Atom and XHTML. So, I’d like to point out a few common XML misconceptions which harm interoperability:
- XML namespaces do not have to be URLs, and XML namespaces which are URLs do not necessarily have to refer to resources that exist or that are meaningful. XML namespaces are URIs, and that by definition includes URNs.
- XML namespace prefixes are arbitrary, and must not be expected to have certain values.
- The default namespace is not as attractive as it seems; it may save typing, but overuse of the default namespace (or defining the default namespace to be different in different parts of a document) will just lead to confusion. Explicit namespace prefixes lead to clarity, particularly where many namespaces are involved.