我是学习XSLT的新手,并且遇到了一些我不太了解的东西。我需要在转换文档之前添加一个XSLT参数。我可以对非IE浏览器做到这一点,像这样:如何使用XSLT转换XML文档并在IE中添加参数?
function loadXMLDoc(dname) {
if (window.XMLHttpRequest) {
xhttp = new XMLHttpRequest();
} else {
xhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET", dname, false);
xhttp.send("");
return xhttp.responseXML;
}
function displayResult() {
xml = loadXMLDoc("cdcatalog.xml");
xsl = loadXMLDoc("cdcatalog.xsl");
// code for IE
if (window.ActiveXObject) {
ex = xml.transformNode(xsl);
document.getElementById("example").innerHTML = 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);
document.getElementById("example").appendChild(resultDocument);
}
}
现在,我可以做到这一点对非IE浏览器,新的XSLT处理器对象制成,样式进口的,你只需前添加参数转化过程。虽然这似乎没有发生在IE版本的代码中,我不能简单地在转换之前添加参数。我大量搜索并看到不同的东西,告诉我创建各种不同MSXML版本的新ActiveX对象,而且我对整个事件深感困惑。
以上面的代码,我该怎么做:
xsltProcessor.setParameter(null,"PARAMNAME","PARAMVALUE");
除了IE浏览器,如果可能,可以有人解释IE如何与XSLT的不同,以FF/O/C的整个概念/其他文明交易浏览器?
我确实找到了该页面并将其剔除,但它显然需要另一个外观。我想我会明天再尝试一次,并用更多的咖啡。在这一点上,我最常被我在不同的代码片段中找到的所有不同的MSXML事物所困惑,哪些是合适的。尽管我感谢你的帮助! – yphmsm 2011-04-04 05:51:18
我认为它是XSLTProcessor.setParameter(“Parameter Name”,“Parameter Value”)而不是XSLTProcessor.addParameter(“Parameter Name”,“Parameter Value”) – Gilbou 2011-06-14 10:51:04