[英]How do I load XSLT Stylesheets in javascript so include is processed?
I'm loading an xslt stylesheet in javascript like this. 我正在像这样在javascript中加载xslt样式表。 I'm only required to support Chrome.
我只需要支持Chrome。
function loadXMLDoc(filename){
xhttp = new XMLHttpRequest();
xhttp.open("GET", filename, false);
xhttp.send("");
return xhttp.responseXML;
}
xsl = loadXMLDoc("../Stylesheets/main.xsl");
xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(xsl);
main.xsl is the main stylesheet and contains a lot of xsl:include references to other xsl stylesheets. main.xsl是主要的样式表,并且包含许多xsl:include对其他xsl样式表的引用。 I need to send an argument somewhere that tells javascript to resolve the include references.
我需要在某个地方发送一个参数,告诉javascript解决包含引用。
I'm not using IE, but it has an ActiveXObject method like: 我没有使用IE,但是它具有ActiveXObject方法,例如:
doc.setProperty('ResolveExternals', true);
Is there some command I can put in my code to 'Resolve Externals' to pull in the stylesheets referenced in main.xsl? 我是否可以在我的代码中添加一些命令以“解决外部问题”,以提取main.xsl中引用的样式表?
Turns out xhttp needed to be a global variable. 原来xhttp必须是全局变量。 I'm not sure why, but it worked.
我不知道为什么,但是它起作用了。
function loadXMLDoc(filename){
var xhttp = new XMLHttpRequest();
xhttp.open("GET", filename, false);
xhttp.send("");
return xhttp.responseXML;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.