In: Categories » » HTML XHTML and CSS » XHTML Namespaces Validation and Other Complexities
Namespaces, Validation, and Other Complexities The XHTML 1.1 specification is lucky. It's all assembled within the same namespace. Extensions have a much harder time negotiating a number of implementation issues involving namespaces and different kinds of XML processing. Because XHTML is the dominant vocabulary when html is the root element, it's quite clear that XHTML documents should declare the default namespace there. On the other hand, it's difficult both to decide what to do with namespace declarations for extensions and how to sensibly include XHTML within other modules. This is because it may not be wise to always assign XHTML the default namespace. Namespace problems arise (for now) because XML 1.0 DTDs are not "namespace-aware." Validating parsers don't interpret prefixes as having any meaning other than a simple string of characters in the name. The Namespaces in XML Recommendation makes it clear that you can change the prefix to something else, while referencing the same URL, and still describe the same thing. Because validating parsers don't recognize namespaces, changing the prefix means that documents claiming to be identical under the Namespaces in XML Recommendation aren't recognized as such by XML 1.0 – and nothing has been done to resolve this. XHTML 1.1 doesn't go to the (admittedly extreme) length of parameterizing element names to allow namespace prefix changes – at least as of the 5 January 2000 Last Call drafts. This means that module developers have to watch out for namespace prefix collisions if they plan to use their modules in environments where they might encounter validating XML parsers – an XML document storage system, for instance. Keeping out of trouble on this issue can be easy, although perhaps not quite perfect. When I chose the prefix for the XHTML-Biography Module, I chose the more verbose (but less common) biog over the easier (but more likely to conflict) bio. The more specific (or downright weird) the prefix you choose, the less likely it is that others will choose the same one and then want to mix their content with yours. This relatively easy strategy may make sense. Another option is to parameterize names within your own documents. This might look like the following code:
<!ENTITY % biog.nsprefix "biog:"> <!ENTITY % biog.nsuri "http://www.simonstl.com/xhtml/xhtml-biography/"> <!ENTITY % biog:biography.element "INCLUDE" > <![%biog:biography.element;[ <!ENTITY biog:biography.content "(biog:title, biog:name, biog:birth, biog:death?, %Block.mix;)"> <!ENTITY % biog.nsElementName "%biog.nsprefix;biography%biog:biography.content;"> <!ELEMENT % biog.nsElementName %biog:biography.content;> ]]> <!ENTITY % biog:biography.attlist "INCLUDE" > <