File: xsltransformjs.js

package info (click to toggle)
whitedune 0.30.10-2.2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster
  • size: 42,004 kB
  • sloc: cpp: 116,017; ansic: 79,688; java: 20,101; sh: 3,248; yacc: 2,902; makefile: 1,717; lex: 848; awk: 363; perl: 270; objc: 143; lisp: 112; python: 22
file content (58 lines) | stat: -rw-r--r-- 1,915 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//original author declares xlstransformjs.js public domain

var oArgs = WScript.Arguments;

if (oArgs.length == 0)
{
    WScript.Echo ("Usage : cscript xsltransformjs.js x3d xsl out");
    WScript.Quit();
}
xmlFile = oArgs(0); //+ ".xml";
xslFile = oArgs(1); //+ ".xsl";
wrlFile = oArgs(2);

var xsl = new ActiveXObject("MSXML2.DOMDOCUMENT.6.0");
var xml = new ActiveXObject("MSXML2.DOMDocument.6.0");
xml.validateOnParse = false;
xml.async = false;
// next few lines from dug, in anticipation of problems with DTD, scripts etc
// http://msdn.microsoft.com/en-us/library/ms763800(VS.85).aspx
xml.setProperty("AllowDocumentFunction", true);
xml.setProperty("AllowXsltScript", true);
xml.resolveExternals = true;
xml.setProperty("ProhibitDTD", false);  //if you have a <DTD> line in your X3D file
//end dug lines
xml.load(xmlFile);

if (xml.parseError.errorCode != 0)
    WScript.Echo ("XML Parse Error : " + xml.parseError.reason);

//how to do: x3d Collision enabled='true' --> vrml97 Collision collide TRUE

xsl.async = false;
// next few lines from dug, in anticipation of problems with DTD, scripts etc
// http://msdn.microsoft.com/en-us/library/ms763800(VS.85).aspx
xsl.setProperty("AllowDocumentFunction", true);
xsl.setProperty("AllowXsltScript", true);
xsl.resolveExternals = true;
xsl.setProperty("ProhibitDTD", false);  //for JScript
//end dug lines
xsl.load(xslFile);

if (xsl.parseError.errorCode != 0)
    WScript.Echo ("XSL Parse Error : " + xsl.parseError.reason);

try
{
    //WScript.Echo (xml.transformNode(xsl.documentElement));
	var str = xml.transformNode(xsl.documentElement);
	var fso = new ActiveXObject("Scripting.FileSystemObject");
	var a = fso.CreateTextFile(wrlFile, true);
	a.Write(str);
	a.Close();
	//WScript.StdOut.Write(str);
}
catch(err)
{
    WScript.Echo ("Transformation Error : " + err.number + "*" + err.description);
}