Last active
December 17, 2015 01:09
-
-
Save serge1/5525827 to your computer and use it in GitHub Desktop.
Invocation of Java Script for XSLT transformation on Windows host
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Possible invocation methods: | |
- Command line console output: | |
cscript test.js | |
- Output in message box: | |
wscript test.js | |
- or, just double click |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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