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

Martin (gzlist) wrote:
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.
The bowels of the "html sanitizer" (I'm sanitizing html email and marking up links to open in new windows, etc) could not cope with that knowledge!
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
Thats the great sort of stuff I needed - thanks very much.


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.

xslt mailing list, project page
xslt gnome org

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