Hi, I have created a Practice.xsl file to transform the source Practice.xml to an html from javascript and add the generated html to n empty DIV element, which is working fine with IE But same html is not rendered correctly on Firefox.
here is the Practice.xml
<feed>
<feedback>
<user>Naresh</user>
<date>12 Oct, 2009</date>
<comments>This blog has no stuff to rate it</comments>
</feedback>
<feedback>
<user>Pokuri</user>
<date>21 Dec, 2009</date>
<comments>Naresh is right</comments>
</feedback>
<feedback>
<user>Subbu</user>
<date>30 Dec, 2009</date>
<comments>I don't agree with both Naresh n Pokuri</comments>
</feedback>
</feed>
Here is the Practice.xsl
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="html" indent="yes"/>
<xsl:template match="feed/feedback">
<html>
<head>
<title>Feedback Forum</title>
</head>
<body>
<span style="display:block; padding: 5px 10px; background-color: #C9F0F9; width: 100%; margin-top:10px; border-left:10px solid #F9EBC9; border-bottom: 1px solid #000000;"><xsl:apply-templates select="user"/> on <xsl:apply-templates select="date"/></span>
<span style="display:block; padding: 5px 10px; background-color: #CDF5CD; width: 100%; border-left:10px solid #F9EBC9;"><xsl:apply-templates select="comments"/></span>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Here is the javascript for work with XSLT transformations on Firefox
function listOrders(){
var XSLT = loadXSLT("Practice.xsl");
var trasformedText;
if(window.ActiveXObject){
trasformedText = XMLDOM.transformNode(XSLT);
document.getElementById("rightDIV").innerHTML=trasformedText;
} else if(document.implementation && document.implementation.createDocument){
**xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(XSLT);
trasformedText = xsltProcessor.transformToFragment(XMLDOM, document);
document.getElementById("rightDIV").appendChild(trasformedText);**
} else {
alert("Sorry your browser may not support xsl transformation.\n+Please check your browser documentation for further help");
}
}
Relative images for professionals to identify the problem easily
In Firefox: http://img97.imageshack.us/img97/8509/firefoxk.jpg