XSL Transformation working in IE, not in Chrome



I'm having a bit of trouble transforming an xml document using the xsl below. The code works on IE using xmlDoc.transformNode, but the following code does not work in chrome - resultDocument returns null.



var xslString = "<xsl:stylesheet version="1.0" xmlns:xsl="http://ift.tt/tCZ8VR">
<xsl:template match="options">
<div id="divAllOpt" class="sDiv" ALL="1" style="FONT-WEIGHT:bold;">
All
</div>
<div id="divGroupOnOpt" class="sDiv" GROUP="1" style="FONT-WEIGHT:bold;">
Group By
</div>
<xsl:apply-templates select="option[. != '']">
<xsl:sort select="."/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="option">
<div class="sDiv">
<xsl:choose>
<xsl:when test="@value">
<xsl:attribute name="VALUE">
<xsl:value-of select="@value"></xsl:value-of>
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="VALUE">
<xsl:value-of select="."></xsl:value-of>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:attribute name="title">
<xsl:value-of select="."></xsl:value-of>
</xsl:attribute>
<xsl:value-of select="."></xsl:value-of>
<xsl:if test="@count">
(<xsl:value-of select="@count"></xsl:value-of>)
</xsl:if>
</div>
</xsl:template>
</xsl:stylesheet>";
var xsltProcessor = new XSLTProcessor();
var xslSheet = new DOMParser().parseFromString(xslString, 'application/xml');
xsltProcessor.importStylesheet(xslSheet);
var resultDocument = xsltProcessor.transformToFragment(xmlDoc.documentElement, document);


The xml document (xmlDoc.documentElement.outerHTML) that I'm trying to transform is as shown below -



"<options>
<option count="3">ABC</option>
<option count="8">XYZ</option>
<option count="32">CVB</option>
<option count="1">TST</option>
<option count="2">CNN</option>
</options>"


Any ideas? Thanks.


No comments:

Post a Comment