4.3 How Parsers Handle Namespaces


Namespaces are not part of XML 1.0. They were invented about a year after the original XML specification was released. However, care was taken to ensure backward compatibility. Thus, an XML parser that does not know about namespaces should not have any trouble reading a document that uses namespaces. Colons are legal characters in XML element and attribute names. The parser will simply report that some of the names contain colons.

A namespace-aware parser does add a couple of checks to the normal well- formedness checks that a parser performs . Specifically, it checks to see that all prefixes are mapped to URIs. It will reject documents that use unmapped prefixes (except for xml and xmlns when used as specified in the XML or "Namespaces in XML" specifications). It will further reject any element or attribute names that contain more than one colon . Otherwise, it behaves almost exactly like a non-namespace-aware parser. Other software that sits on top of the raw XML parseran XSLT engine, for examplemay treat elements differently depending on which namespace they belong to. However, the XML parser itself mostly doesn't care as long as all well-formedness and namespace constraints are met. Many parsers let you turn namespace processing on or off as you see fit.

XML in a Nutshell
XML in a Nutshell, Third Edition
ISBN: 0596007647
EAN: 2147483647
Year: 2003
Pages: 232

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net