Re: [xsl] Apologies and 2 questions

Subject: Re: [xsl] Apologies and 2 questions
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Mon, 23 Jul 2001 10:56:50 +0100
Hi Nathan,

> BUT, when the XML is parsed by the XSLT, it outputs the <br /> tag
> as <br>. If I am using the XHTML1.0 Transitional DTD to define my
> output, it will not validate. It needs to be output as <br />. Same
> goes for any other standalone tags <img />, <hr />, <input />,
> etc.... Does that make sense?

Yes. You are using the 'html' output method when you want the output
to be XML. To make the processor output well formed XML, you need to
use the 'xml' output method:

<xsl:output method="xml" />

The empty elements will be output as empty elements and so on.
*However* the XML output method has no awareness that it is outputting
XHTML, so it doesn't do some things that you get automatically from
the HTML output method, like nice character entity references and
escaping of URI attribute values. It also means that you probably
don't get the compatibility features of XHTML, like having a space
before the / in empty elements.

To have that kind of stuff done for you, you really need a dedicated
XHTML output method. Some processors offer this as an extension output
method, for example Saxon allows you to do:

<xsl:output method="saxon:xhtml" />

(An XHTML output method is something that *might* be supported in XSLT
2.0 - it's requirement 1.8, but only a 'could'.)

The other option is outputting HTML and then tidying it into XHTML
with HTML Tidy.



Jeni Tennison

 XSL-List info and archive:

Current Thread