简体   繁体   中英

How do I load XSLT Stylesheets in javascript so include is processed?

I'm loading an xslt stylesheet in javascript like this. I'm only required to support 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. I need to send an argument somewhere that tells javascript to resolve the include references.

I'm not using IE, but it has an ActiveXObject method like:

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?

Turns out xhttp needed to be a global variable. 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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM