Fulfill XHTML compat requirements with XSLT output

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Fulfill XHTML compat requirements with XSLT output

Post 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?
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Post 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?
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post 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.
Post Reply