Skip to content

Instantly share code, notes, and snippets.

@ericlaw1979
Created October 6, 2021 16:17
Show Gist options
  • Save ericlaw1979/deb716d8436890420c41c8a593bfd509 to your computer and use it in GitHub Desktop.
Save ericlaw1979/deb716d8436890420c41c8a593bfd509 to your computer and use it in GitHub Desktop.
Transform XML+XSLT to plain html so that it loads without blocking (see https://textslashplain.com/2019/10/09/navigating-to-file-urls/ )
// Filenames
var sXML = "U_MS_Edge_V1R3_STIG_Manual-xccdf.xml";
var sXSLT = "STIG_unclass.xsl";
var sOutput = "TransformedHTML.html";
var fso, f, xmlstr, xsltstr;
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.OpenTextFile(sXML);
xmlstr = f.ReadAll();
f.Close();
f = fso.OpenTextFile(sXSLT);
xsltstr = f.ReadAll();
f.Close();
var xmldom, xsltdom;
try {
xmldom = new ActiveXObject("Msxml2.DOMDocument.6.0");
xmldom.validateOnParse = true;
xmldom.async = false;
xmldom.loadXML(xmlstr);
xsltdom = new ActiveXObject("Msxml2.DOMDocument.6.0");
xsltdom.validateOnParse = true;
xsltdom.async = false;
xsltdom.loadXML(xsltstr);
output = xmldom.transformNode(xsltdom);
f = fso.CreateTextFile(sOutput);
xsltstr = f.Write(output);
f.Close();
WScript.echo("Transformed [" + sXML + "] with [" + sXSLT +"] to make [" + sOutput + "]");
}
catch(err) {
WScript.echo(err.description);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment