[web] Embed HTML in XML with Fire Fox 1.04

Started by
1 comment, last by QuiOui 18 years, 8 months ago
I'm trying to write a webpage to publish some of my active projects, so I have put together few .xml pages as well as the accompanying .xsl files. Using disable-output-escaping="yes" in the style sheets and CDATA tags in the XML documents, I managed to encode HTML source code into regular XML tags and have it execute and display well formatted HTML stuff such on IE. Using FireFox 1.04 however I can see that the HTML code is just being printed out as it is without interpretation or whatsoever. Now the question is; is this is a bug related to FF or am I missing something? Here is a link to my upcoming webpage
Advertisement
Having disable-output-escaping is NOT the correct way to output HTML. You should leave output escaping enabled, and set the XML namespace correctly so that normal elements in the xslt are output as XHTML.

As long as it's well-formed, you can then just stick plain xhtml elements anywhere in your XSLT (provided the default namespace is xhtml).

I don't know whether Mozilla will be able to activate its legacy HTML parser from an XML document - possibly not - in which case, your output MUST BE WELL FORMED XHTML.

In any case, outputting not-well-formed HTML from an XSLT is an incredibly evil thing to do, and you shouldn't do it anyway :)

Remember that Mozilla has a HTML parser and a XML parser, and they are NOT the same. XSLT is running through the XML parser, therefore has to be well-formed. This has nothing to do with "quirks mode", which only applies to HTML.

Mark
Since it's been a few months now, I am not sure if you have already resolved the issue. Looking at the website link, you might not have. Here is the solution anyway. You can use employ some &#106avascript to populate a <div> with CDATA.

Here is the script:
function loadDOE() {    var elements = document.getElementsByTagName('div');    for (var i = [[[[0]]]]; i < elements.length; i++) {        var el = elements;        if (el.className == 'replacewithyourclassname') 		{            el.innerHTML = el.firstChild.data;        }    }}

And here is the xsl:

<xsl:choose>
<xsl:when test="system-property('xsl:vendor')='Transformiix'">
<div class="replacewithyourclassname"><xsl:value-of select="." disable-output-escaping="yes"/><script language="&#106avascript" type="text/&#106avascript"&gt;loadDOE()&lt;/script&gt;</div><br> &lt;/xsl:when&gt;<br> &lt;xsl:otherwise&gt;<br> &lt;xsl:value-of select="." disable-output-escaping="yes"/&gt;<br> &lt;/xsl:otherwise&gt;<br> &lt;/xsl:choose&gt;<br><br><br>QuiOui

This topic is closed to new replies.

Advertisement