谁能告诉我为什么下面的XSL在IE9中愉快地转换下面的XML,但是在所有版本的Visual Studio下,相同的转换都失败了?如果我在IE 9中打开XML文件,它会被转换并且输出如预期的那样,但是如果我在Visual Studio中对XML文件进行相同的转换(使用工具栏上的“启动XSLT”按钮),我会得到一个JScriptException话说功能有望上线Visual Studio和IE之间行为的XSL/JScript差异
var node = root.nextNode();
的修复似乎是改变javascript函数来做,而不是执行以下操作:
function test(root, attr)
{
root.MoveNext();
var node = root.Current;
return node.Select("breakfast" + attr);
}
但这种失败,则在IE中XSLT转换!我似乎无法取胜!
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>
目标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>
谢谢 - 我想你已经找到了答案。我不打算为两者开发,我想这只是一个工作流程问题 - 我在部署在IE上之前在Visual Studio中进行了调试,所以这给我带来了一些麻烦。 – 2011-05-23 11:33:42