我有以下代码应用XSLT样式
Test.Xml.xslTransform = function(xml, xsl) {
try {
// code for IE
if (window.ActiveXObject) {
ex = xml.transformNode(xsl);
return ex;
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument) {
xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(xsl);
resultDocument = xsltProcessor.transformToFragment(xml, document);
return resultDocument;
}
} catch (exception) {
if (typeof (exception) == "object") {
if (exception.message) {
alert(exception.message);
}
} else {
alert(exception);
}
}
Run Code Online (Sandbox Code Playgroud)
该代码适用于IE和Firefox,但不适用于Chrome和Safari.有什么想法吗?
更新
ResultDocument = xsltProcessor.transformToFragment(xml, document);
Run Code Online (Sandbox Code Playgroud)
上面的行返回null.没有错误被抛出.
更新
由于xslt文件包含xsl:include,因此代码无效.需要找到一种方法来使包含工作我将在此处粘贴进度
更新
我建议使用http://plugins.jquery.com/project/Transform/插件.我正在尝试使用客户端libary作为include的示例( …
我正在尝试使用远程XSL样式表加载本地XML文件.IE似乎处理这个很好,但不是Firefox.有没有解决这个问题?