Subject: RE: [xsl] Command Line XSLT programs From: "Bryan Rasmussen" <bry@xxxxxxxxxx> Date: Thu, 14 Mar 2002 10:43:46 +0100 |
> > Dru Sellers wrote: > > > Does anyone know if it is possible to apply an XSLT to multiple XML docs > 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; domStyle.load(style); 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; //WScript.Echo(domFiles.xml) //WScript.Echo(domFiles.documentElement.xml) var fileNodeList=domFiles.documentElement.selectNodes('./file') //WScript.Echo(fileNodeList.length) for (var i = 0 ; i < fileNodeList.length ; i++) { //WScript.Echo(fileNodeList(i).xml) //WScript.Echo(fileNodeList(i).attributes.getNamedItem('name').text) 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.... //root.childNodes.item(i).text; //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; //WScript.Echo(file1); domSource.load(file1); //WScript.Echo(domSource.xml); //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); objNewFile.Write(result.toString()); objNewFile.Close(); } 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\" type="xml"/></file_list> 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: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Command Line XSLT program, s . livingstone | Thread | [xsl] XML to PDF and greek letters, Eric . Reiter |
RE: [xsl] EXSLT in ASP.NET?, Bryan Rasmussen | Date | RE: [xsl] implementing XPath over a, Bryan Rasmussen |
Month |