XML technologies / XML / XML in a Nutshell / Namespaces / How parsers handle Namespaces.

(Excerpt from "XML in a Nutshell" by Elliotte Rusty Harold & W. Scott Means)

Namespaces are not part of XML 1.0. They were introduced a year after the XML specification was published, with care taken to preserve backward compatibility. This means that a XML parser, even if unaware of namespaces, should have no problem reading a document that uses them. Colons are valid characters in XML element and attribute names, so the parser simply reports names containing colons.

A namespace-aware parser performs additional checks beyond the usual checking of well-formedness. In particular, it checks that all prefixes are mapped to URIs and rejects documents using unbound prefixes. The only exceptions are xml and xmlns, when used as defined in the XML specification or the specification Namespaces in XML. It also rejects element or attribute names containing more than one colon. Otherwise, it behaves much like a parser without namespace support. Other programs built on a plain XML parser, such as an XSLT engine, may treat elements differently depending on the namespace they belong to. The XML parser usually does not care, provided well-formedness and namespace requirements are satisfied. Many parsers let you enable or disable namespace processing as needed.

  

 

 

 

back to top