TransformToDocument is not working in FireFox



this is my xsl:-



<xml id="propertiesXSL" style="display:none;">
<xsl:stylesheet version="1.0" xmlns:xsl="http://ift.tt/tCZ8VR">
<xsl:template match="/">
<table cellpadding="0" cellspacing="0" border="0" width="100%" id="propertiesDataTable" class="data_table">
<tr>
<th align="left" width="30%" style="white-space:nowrap">Name</th>
<th align="left" width="65%" style="white-space:nowrap">Value</th>
<th align="left" width="5%" style="white-space:nowrap">Encrypted</th>
</tr>
<xsl:for-each select="properties/property[not(isHidden = 'true')]">
<xsl:variable name="index" select="index" />
<tr>
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="position() mod 2 = 0">odd_table_row</xsl:when>
<xsl:otherwise>even_table_row</xsl:otherwise>
</xsl:choose>
</xsl:attribute>

<td class="checkBox_Column" align="center">
<xsl:choose>
<xsl:when test="isRequired = 'true'">
<img src='$link.contextPath/images/space.gif' width='20' height='20' border='0' align='absmiddle' id='actionTabImage'></img>
</xsl:when>
<xsl:otherwise>
<input type="checkbox" id="propertyIndex{index}" name="propertyIndex{index}" value="{index}" onclick="handlePrefixedCheckboxSelection(this,'propertyIndex',true);" />
</xsl:otherwise>
</xsl:choose>
</td>

</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
</xml>


and this is my xml:-



<textarea name="propertiesXML" id="propertiesXML" style="display:none;">
<?xml version="1.0" encoding="UTF-8" ?>
<properties>
</properties>


and i had one div defined in the form of tr and td:-



<table>
<tr>
<td nowrap align="left" colspan="2" width="100%">
<div class="table_div" id ="propertiesContainer" style="height:$height;width:100%;position:relative;overflow-y:scroll;overflow-x:scroll;"></div>
</td>
</tr>
</table>


and my javascript code is



<script language="javascript" type="text/javascript">
var properties_xmlDoc = null;

function loadProperties()
{
var oXSLContainer = document.getElementById("propertiesXSL");
var oXMLContainer = document.getElementById("propertiesXML");
var oHTMLContainer = document.getElementById("propertiesContainer");

if (properties_xmlDoc == null)
{
// code for loading the XML :- here is fiddle link [http://ift.tt/1qQ2YIm]
properties_xmlDoc = loadXMLFromString(oXMLContainer.value);
}
// for IE
if(window.ActiveXObject){
// this line is working fine for IE
oHTMLContainer.innerHTML = new String(properties_xmlDoc.transformNode(oXSLContainer));
}
//for FF,chrome
else if(document.implementation && document.implementation.createDocument){
var xslTransform = document.implementation.createDocument("", "doc", null);
var serializer = new XMLSerializer();
xslTransform.async=false;
xslTransform.load(oXSLContainer);
var xslResult = new XSLTProcessor();
xslResult.importStylesheet(xslTransform);
// the below line doesn't result output in firefox as it was working in IE
var htmlResult_xmlDoc = xslResult.transformToDocument(properties_xmlDoc);
var xml = (new XMLSerializer()).serializeToString(htmlResult_xmlDoc);
oHTMLContainer.innerHTML = xml;
}
}
</script>


what my code will do is it will process the xmlfile i.e.propertiesXML by using the supplied XSL i.e. propertiesXSL and returns the resulting transformation into oHTMLContainer into row format i.e Name,Value and Encrypted.


For internet Explorer



oHTMLContainer.innerHTML = new String(properties_xmlDoc.transformNode(oXSLContainer));


by the above line the 3 row i.e Name,Value,Encrypted will get generated properly


but when i am trying for Firefox with the below line :-



var htmlResult_xmlDoc = xslResult.transformToDocument(properties_xmlDoc);


it is not getting generated. Even firebug is showing error like htmlNotfound.


Can some one please point out and help me out , what exactly going wrong. Gone through blogs and several links but unfortunately not able to find out the issue.


Thanks


No comments:

Post a Comment