Re: [xslt] avoid self-closing tags on ouptut?

On 09/10/2009, Sam Liddicott <sam liddicott com> wrote:
> So although libxml2's html parsing of "tag soup" is a boon, unless I
> want to present the output as text/xml (which I do not) I'm in trouble.

There are well documented ways of varying content-type so you can tell
sane browsers what you're sending is actually xml, while maintaining
compatability with less capable user agents.

Also, using one of the XHTML 1.0 doctypes will make the serialiser use
the appendix C compatibility hacks. The output doesn't even need to be

Stylesheet (applied to any input):

<xsl:stylesheet xmlns="";
    version="1.0" >

    <xsl:output omit-xml-declaration="yes"
        doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"

    <xsl:template match="/">


Outputs (amusingly bogus):

<!DOCTYPE p PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<p xmlns="";><tt></tt><br /></p>

Using the same <xsl:output/> in your transform should give you a
result that html parsers old and new don't get too confused over.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]