I have the following code in my xsl document : I tried to apply it but it is returning the following error: Error:XSLTProcessor::transformToXml() [xsltprocessor.transformtoxml]: XPath evaluation returned no result. Does any one have an idea ??
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:user="http://mycompany.com/mynamespace"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" version="1.0">
<xsl:output method="text" encoding="UTF-8" />
<xsl:template match="/">
<xsl:value-of select="CARRIERNAME"/>
<xsl:value-of select="user:FormatescapeEmbeddedCommas()"/>
</xsl:template>
<msxsl:script language="javascript" implements-prefix="user">
function FormatescapeEmbeddedCommas() {
return "ABC";
}
</msxsl:script>
</xsl:stylesheet>
Support for the Microsoft extension for scripting in XSL is not available in Chrome.
If you want your XSL to work in browsers, have a look at this XSLT browser comparison chart, as cross-browser support is unfortunately quite limited.
Best bet is to use XSLT 1.0-only constructs, to not use external documents (
xsl:import
, thedocument()
function), because these are blocked by default in Chrome, and if you need functions, use named templates, as it will be tricky to create a cross-browser extension function (I'm not sure if Chrome supports this at all, but definitely not with the MS namespace).If you do need to use vendor-specific extensions, make sure to add
xsl:if
around these instructions with a test-clause usingsystem-property('xsl:vendor')
, which will check in what browser you are.I find the given error rather odd, I would have expected it to be something like "function not found".
Note that by default, even in Internet Explorer, XSLT scripts are disabled by default.
If you have any chance of running your stylesheet outside the browser, you will likely save yourself a lot of trouble and precious time, and it may enable you to use XSLT 2.0 or 3.0 instead of only XSLT 1.0. Saxon has a JS-powered version of their XSLT 2.0 processor called Saxon-CE, and Frameless is a cross-browser implementation of a large part of the XSLT 2.0 specification and claims to be lightweight. The requirement to use extension functions or instructions is much less with XSLT 2.0 as it is more flexible and allows you to create your own stylesheet functions using
xsl:function
.