Can anyone tell me why the following XSL happily transforms the XML below in IE9, but the same transform fails under all versions of Visual Studio? If I open the XML file in IE 9, it gets transformed and the output is as expected, but if I attempt the same transform on the XML file in Visual Studio (using the 'Start XSLT' button on the toolbar) I get a JScriptException saying function expected on the line
var node = root.nextNode();
The fix seems to be to change the javascript function to do the following instead:
function test(root, attr)
{
root.MoveNext();
var node = root.Current;
return node.Select("breakfast" + attr);
}
But this then fails the XSLT transform in IE! I can't seem to win!
XSL:
<!--<?xml version="1.0"?>-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="urn:custom-scripts">
<msxsl:script language="JScript" implements-prefix="user">
<![CDATA[
function test(root, attr)
{
var node = root.nextNode();
return node.selectSingleNode("breakfast" + attr);
}
]]>
</msxsl:script>
<xsl:template match="/">
<HTML>
<BODY STYLE="font-family:Arial, helvetica, sans-serif; font-size:12pt;
background-color:#EEEEEE">
<xsl:value-of select="user:test(., '-menu')"/>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
Target XML:
<?xml version='1.0'?>
<?xml-stylesheet type="text/xsl" href="simple.xsl" ?>
<breakfast-menu>
<food>
<name>Belgian Waffles</name>
<price>$5.95</price>
<description>Two of our famous Belgian Waffles
with plenty of real maple syrup.</description>
<calories>650</calories>
</food>
<food>
<name>Homestyle Breakfast</name>
<price>$6.95</price>
<description>Two eggs, bacon or sausage, toast,
and our ever-popular hash browns.</description>
<calories>950</calories>
</food>
</breakfast-menu>