Changes for page Engine_MSXML

Last modified by Nicolas Gregoire on 2012/01/14 16:51

From version Icon 5.1 Icon
edited by Nicolas Gregoire
on 2012/01/10 11:37
Change comment: There is no comment for this version
To version Icon 6.1 Icon
edited by Nicolas Gregoire
on 2012/01/10 11:38
Change comment: Upload new attachment msxslt.js

Summary

Details

Icon msxslt.js
Author
... ... @@ -1,0 +1,1 @@
1 +xwiki:XWiki.NicolasGregoire
Size
... ... @@ -1,0 +1,1 @@
1 +1.2 KB
Content
... ... @@ -1,0 +1,49 @@
1 +var adTypeBinary = 1;
2 +var adSaveCreateOverWrite = 2;
3 +var adSaveCreateNotExist = 1;
4 +
5 +try
6 +{
7 + var args = WScript.Arguments;
8 +
9 + if(args.length < 3)
10 + {
11 + WScript.Echo("Usage: msxslt.js file.xml file.xsl output.txt");
12 + WScript.Quit(1);
13 + }
14 + else
15 + {
16 + var xml = args(0);
17 + var xsl = args(1);
18 + var out = args(2);
19 +
20 + var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.6.0");
21 + var xslDoc = new ActiveXObject("Msxml2.DOMDocument.6.0");
22 + /* You need this line to execute <script> tags */
23 + xslDoc.setProperty('AllowXsltScript', true);
24 +
25 + /* Create a binary IStream */
26 + var outDoc = new ActiveXObject("ADODB.Stream");
27 + outDoc.type = adTypeBinary;
28 + outDoc.open();
29 +
30 + if(xmlDoc.load(xml) == false)
31 + {
32 + throw new Error("Could not load XML document " + xmlDoc.parseError.reason);
33 + }
34 +
35 + if(xslDoc.load(xsl) == false)
36 + {
37 + throw new Error("Could not load XSL document " + xslDoc.parseError.reason);
38 + }
39 +
40 + xmlDoc.transformNodeToObject(xslDoc, outDoc);
41 + outDoc.SaveToFile(out, adSaveCreateOverWrite);
42 + }
43 +}
44 +catch(e)
45 +{
46 + WScript.Echo(e.message);
47 + WScript.Quit(1);
48 +}
49 +