RE: [xsl] Trouble with namespaces and running identity transform on XHTML

Subject: RE: [xsl] Trouble with namespaces and running identity transform on XHTML
From: "James J. Ramsey" <jjramsey_6x9eq42@xxxxxxxxx>
Date: Thu, 11 Mar 2004 09:14:38 -0800 (PST)
--- Michael Kay <mhk@xxxxxxxxx> wrote:
> There is a problem generating XHTML, or any other
> XML format that requires
> specific prefixes to be declared. The XSLT 2.0 spec
> acknowledges this with a
> fudge, simply pointing out that if the result tree
> is going to be serialized
> as XHTML then it's a good idea for the namespace
> fixup process to take this
> into account when allocating prefixes.

My reading of the XSLT 2.0 spec, or more to the point
the XSLT 2.0 and XQuery 1.0 Serialization spec, is a
bit more strongly worded than that. The XHTML output
method is supposed to "output namespace declarations
in a way that is consistent with the requirements of
the XHTML DTD if this is possible."
<http://www.w3.org/TR/xslt-xquery-serialization/#xhtml-output>

> XSLT 1.0
> gives you no guarantees
> about the prefixes used in the output and therefore
> no reliable and portable
> way of generating XHTML that validates against the
> XHTML DTD. In practice
> it's usually not a problem because most XSLT
> processors take the path of
> least resistance.

So, if I'm looking at XSLT tools rather than some
flavor of macros or Perl scripts (which are starting
to look pretty good right now), my choices are

* write an XSLT 1.0 stylesheet so that when it is
processed by an XSLT 1.0 processor, the serializer
will never find adding namespace prefixes to be the
path of least resistance. That seems to mean avoiding
declaring a prefix for the XHTML namespace in the XSL
stylesheet, and avoiding using the "namespace"
attribute of xsl:element.

* Use an XSLT processor that implements the
almost-ready-for-primetime spec for XSLT 2.0. The main
downsides to this are that the XSLT 2.0 spec is still
in flux and that, AFAIK, there is only one stable XSLT
processor that implements the XSLT 2.0 spec, namely
Saxon. At least one upside is that I shouldn't need a
separate filter (like HTML Tidy) to add whitespace
before the "/>" in the tags for empty elements.


__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you?re looking for faster
http://search.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread