Windows script to run an XML transform.
authorcantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Sun, 17 Feb 2008 21:19:07 +0000 (21:19 +0000)
committercantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Sun, 17 Feb 2008 21:19:07 +0000 (21:19 +0000)
git-svn-id: https://svn.middleware.georgetown.edu/cpp-sp/trunk@2738 cb58f699-b61c-0410-a6fe-9272a202ed29

configs/xsltproc.js [new file with mode: 0644]

diff --git a/configs/xsltproc.js b/configs/xsltproc.js
new file mode 100644 (file)
index 0000000..9f961ee
--- /dev/null
@@ -0,0 +1,32 @@
+var oArgs = WScript.Arguments;
+
+if (oArgs.length < 2) {
+    WScript.Echo("usage: cscript xslt.js xml xsl");
+    WScript.Quit();
+}
+
+xslFile = oArgs(0);
+xmlFile = oArgs(1);
+
+var xsl = new ActiveXObject("MSXML2.DOMDocument");
+var xml = new ActiveXObject("MSXML2.DOMDocument");
+
+xml.validateOnParse = false;
+xml.async = false;
+xml.load(xmlFile);
+
+if (xml.parseError.errorCode != 0)
+    WScript.Echo("XML Parse Error: " + xml.parseError.reason);
+
+xsl.async = false;
+xsl.load(xslFile);
+
+if (xsl.parseError.errorCode != 0)
+    WScript.Echo("XSL Parse Error: " + xsl.parseError.reason);
+
+try {
+    WScript.Echo(xml.transformNode(xsl.documentElement));
+}
+catch(err) {
+    WScript.Echo("Transformation Error: " + err.number + "*" + err.description);
+}