RE: [serialization] XHTML output method

> Section 5 XHTML Output method:
> 
> "The serializer should output namespace declarations in a way 
> that is consistent with the requirements of the XHTML DTD if 
> this is possible. The DTD requires the declaration 
> xmlns="http://www.w3.org/1999/xhtml" to appear on the html 
> element, and only on the html element."
> 
> The first 'should' should be a 'must' or it would make the 
> statement allow serialisations that are not XHTML. XHTML1 says:
> 
> "The root element of the document must contain an xmlns 
> declaration for the XHTML namespace [XMLNS]."

There is a problem here, with no easy fix. The problem is that namespace
prefixes are in general allocated during the namespace fixup process, not by
the serializer. A requirement, such as that in the XHTML spec, to use
particular namesace prefixes (in this case the empty prefix) is not really
consistent with the XPath data model. In practice many implementations
retain more knowledge of prefixes than the spec requires, and they generate
predictable prefixes even where the spec doesn't require it, so they have
ways to overcome this problem. But it's very difficult to formalize this
without extending the data model; hence the choice of "should" rather than
"must".

There are of course many result trees that cannot be serialized as correct
XHTML, and the spec tries to make it clear that selecting the XHTML output
method is no guarantee that the serialized output will be valid according to
the XHTML DTD. This case is rather unusual, however, in that the production
of correct XHTML requires more control over namespace prefixes than the XSLT
and XQuery specifications actually provide.

Michael Kay


> 
> Cheers,
> 
> Max.
> 
> PS. all the examples of minimised elements are written with 2 
> spaces, as in "The serializer should include a space before 
> the trailing />, e.g. <br  /> "
> 

Received on Sunday, 1 June 2003 18:46:17 UTC