Altova Mailing List Archives

RE: [xsl] Command Line XSLT programs

From: "Bryan Rasmussen" <bry@---------->
Date: 3/13/2002 11:42:00 PM
> > Dru Sellers wrote:
> > > Does anyone know if it is possible to apply an XSLT to multiple XML
> at
> > > the same time. My company has a "document-base" in XML that they want
> > > converted into HTML. So instead of me doing them one by one with MSXSL
> and
> > > MSXML 4.0.
> > >
> > > Any ideas?

here's an example adapted from an asp batch processor that was in an article
about 2 years ago in AspToday I started porting it to wscript yesterday and
changed it to use a filelist we're using, this is dirty code but it works so
I don't mind sharing.

okay first you have a .js script, as follows(could also be vbscript, since
wscript handles both):

var domFiles, root, wargs

	wargs = WScript.Arguments;
	var arg1 = WScript.Arguments(0);

	// get the set of files to process
	domFiles = new ActiveXObject("Microsoft.XMLDOM");
//	domFiles.async = false;
	var style= WScript.Arguments(4);
		domStyle = new ActiveXObject("Microsoft.XMLDOM");
		domStyle.async = false;

		var header = "\<\?xml version\=\"1.0\" encoding\=\"iso-8859-1\"\?\>";

	if (!domFiles.load(arg1))
		//WScript.Echo('file not found')
	//if (domFiles.parseError != 0)
		//WScript.Echo(domFiles.url + ": " + domFiles.parseError.reason + "<BR

	//var root = domFiles.documentElement;

		var fileNodeList=domFiles.documentElement.selectNodes('./file')

		for (var i = 0 ; i < fileNodeList.length ; i++)

		domSource = new ActiveXObject("Microsoft.XMLDOM");
		domSource.async = false;

		//get file name from file list
		var fileget = fileNodeList(i).attributes.getNamedItem('name').text

		//get file path from file list
		var filePath= fileNodeList(i).attributes.getNamedItem('path').text

		//get file type from filelist(not really necessary for dom loading
scripts, but  could  		//be useful elsewhere...)
		var fileType= fileNodeList(i).attributes.getNamedItem('type').text

//replaced code....
		//var fpath = WScript.Arguments(1);
// end replaced code

		//concatenate full file path
 		file1 = filePath + fileget +  '.' + fileType;

		//do stuff that you gotta do with file
		opath = WScript.Arguments(3);
		var file = opath + fileget;
		//if (domSource.parseError != 0)
//		WScript.Echo(domSource.url + ": " + domSource.parseError.reason);
result = domSource.transformNode(domStyle);

		result =  header + result;

		var objFSO = new ActiveXObject("Scripting.FileSystemObject");
		var location =  file + WScript.Arguments(2);

		var objNewFile = objFSO.CreateTextFile(location);


	this loads an xml file, as follows:
<file_list><file name="ENWelcome"  path="file:///e:\LocalProjects\Itni
skProduct\ProductExe\SITES\Bordeaux Test1\SITEROOT\content\default\"
type="xml"/><file name="ENIdea"  path="file:///e:\LocalProjects\Itni
skProduct\ProductExe\SITES\Bordeaux Test1\SITEROOT\content\default\"

disregard the path attribute am not making use of that, am instead passing
in the path as an argument to the wscript. this what all those
WScript.Arguments are about, here's a .bat	 file
the first argument WScript.Arguments(0) is an xml file, the second is the
folder where you're pulling your files for transformation the third is the
extension you want to output the fourth is the folder you want to output to
and the fifth is your xsl.

make.js XMLsrcList.xml .\content\ .fo .\output\ make.xsl

 XSL-List info and archive:


These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.