Changes for page Engine_MSXML

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

From version Icon 4.1 Icon
edited by Nicolas Gregoire
on 2012/01/04 22:29
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 Page properties
Content
... ... @@ -1,9 +1,15 @@
1 1  [[MSXML>>http://msdn.microsoft.com/en-us/data/bb291077||rel="__blank" title="MS XML MSDN Page"]] is a XSLT engine by Microsoft.
2 2  
3 3  
4 -Supported XSLT version : 1.0
4 +== Supported version ==
5 5  
6 +1.0
6 6  
8 +== Command line ==
9 +
10 +C:\> wscript.exe msxslt.js file.xml file.xsl output.txt
11 +
12 +
7 7  == Identification strings ==
8 8  
9 9  | xsl:vendor-url|http:~/~/www.microsoft.com
... ... @@ -10,7 +10,6 @@
10 10  | xsl:vendor|Microsoft
11 11  | xsl:version|1
12 12  
13 -
14 14  == Special features ==
15 15  
16 16  * Code execution (desactivated by default in v6)
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 +