Sign in to follow this  

[web] Embed HTML in XML with Fire Fox 1.04

This topic is 4510 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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 javascript 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[i];
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="javascript" type="text/javascript">loadDOE()</script>

</xsl:when>
<xsl:otherwise>
<xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:otherwise>
</xsl:choose>


QuiOui

Share this post


Link to post
Share on other sites

This topic is 4510 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this