Skip to content

Instantly share code, notes, and snippets.

@serge1
Last active December 17, 2015 01:09
Show Gist options
  • Save serge1/5525827 to your computer and use it in GitHub Desktop.
Save serge1/5525827 to your computer and use it in GitHub Desktop.
Invocation of Java Script for XSLT transformation on Windows host
Possible invocation methods:
- Command line console output:
cscript test.js
- Output in message box:
wscript test.js
- or, just double click
var xmlstr = "<object><name>apple</name><color>Red</color></object>";
var xsltstr = '<?xml version="1.0"?>' +
'<xsl:stylesheet ' +
' version="1.0" ' +
' xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> '+
' <xsl:output method="text"/> '+
' <xsl:template match="/object"> '+
' <xsl:value-of select="color"/> '+
' <xsl:value-of select="name"/> '+
' </xsl:template> '+
'</xsl:stylesheet>';
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);
WScript.echo(output);
}
catch(err) {
WScript.echo(err.description);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment