Page 1 of 1

Fulfill XHTML compat requirements with XSLT output

Posted: Sat Sep 09, 2006 7:05 pm
by Ambush Commander
Using this XSLT:

Code: Select all

<xsl:output
        method      = "xml"
        encoding    = "UTF-8"
        doctype-public = "-//W3C//DTD XHTML 1.0 Transitional//EN"
        doctype-system = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
        indent = "yes"
        media-type = "text/html"
    />
I've been outputting XHTML. This works fairly well, but there's one trouble: Empty elements are expressed like this: <br/>. Being the perfectionist I am, I know that for compatibility reasons they should be <br /> (note the extra space). I've searched high and low for the ability to do this and have been unable to find it, so I'm fudging it with:

Code: Select all

$html_output = str_replace('/>', ' />', $html_output); // empty element " />"
...but I suspect this is less than ideal, especially if there's a CDATA section hanging out. Anyone know the answer, or is this fine as it is?

Posted: Mon Sep 11, 2006 3:52 pm
by kendall
Ambush Commander,

uhm....are you serious? 8O ...i've got only one thing to say to you man
Life is not perfect
Does it really make a big difference?

Posted: Mon Sep 11, 2006 7:54 pm
by Ambush Commander
Well, I suppose. It's very possible that 1. I'm using other elements in my pages that prevent older-generation browsers from using the page anyway or 2. Those browsers aren't worth supporting. However, the extra space before the trailing slash is something I'm very used to... in fact, I use it for my pure XML documents too.