Subject: RE: [xsl] simple method for listing directory contents? From: DPawson@xxxxxxxxxxx Date: Thu, 14 Feb 2002 15:06:53 -0000 |
For this I use Chris's javascript (win32 env). At end of email. This provides a nice format of all files recursively. dirtoxml.js <directory> ><outputFile> Processing this with <xsl:template match="folder[@dirroot]"> <h3>This stylesheet was applied from directory <xsl:value-of select="@dirroot"/></h3> <xsl:apply-templates select="file[contains(@name, 'xsl')] [not(contains(@name,'#'))] [not(contains(@name,'~'))]" mode="revs"/> <xsl:apply-templates select="folder"/> </xsl:template> selects all the .xsl files. A similar filter will pick all xml files. HTH. DaveP. //debugger; var G_Fso = new ActiveXObject("Scripting.FileSystemObject"); var oArgs = WScript.Arguments; if (WScript.Arguments.Length < 2){WScript.Echo("Usage : dirTOxml.js folder xmlfile");WScript.Quit();} var folder = G_Fso.getFolder(oArgs(0)); var outFile = G_Fso.createTextFile(oArgs(1), true, false); var depth = 0; var number=0; outFile.WriteLine("<?xml version=\"1.0\"?>"); outFile.WriteLine("<?xml-stylesheet type=\"text/xsl\" href=\"folder.xsl\"?>"); outFile.WriteLine("<folder name=\"" + folder.name + "\" dirroot=\"" + folder.path + "\">"); recurseFolder(folder, outFile, depth); outFile.close(); function recurseFolder(folder, outFile, d){ d++; for (var enumerator = new Enumerator( folder.SubFolders ); !enumerator.atEnd(); enumerator.moveNext() ) { outFile.WriteLine(pad(d) + "<folder name=\"" + enumerator.item().name + "\" number=\"" + number + "\" >"); recurseFolder(enumerator.item(), outFile, d); } for (var enumerator = new Enumerator( folder.files ); !enumerator.atEnd(); enumerator.moveNext() ) { outFile.WriteLine(pad(d) + "<file name=\"" + enumerator.item().name + "\" number=\"" + number + "\" />"); number++; } outFile.WriteLine(pad(d-1) + "</folder>") } function pad(x){ var t=""; for (i=0; i < x; i++){ t += "\t"; } return t; } - NOTICE: The information contained in this email and any attachments is confidential and may be legally privileged. If you are not the intended recipient you are hereby notified that you must not use, disclose, distribute, copy, print or rely on this email's content. If you are not the intended recipient, please notify the sender immediately and then delete the email and any attachments from your system. RNIB has made strenuous efforts to ensure that emails and any attachments generated by its staff are free from viruses. However, it cannot accept any responsibility for any viruses which are transmitted. We therefore recommend you scan all attachments. Please note that the statements and views expressed in this email and any attachments are those of the author and do not necessarily represent those of RNIB. RNIB Registered Charity Number: 226227 Website: http://www.rnib.org.uk 14th June 2002 is RNIB Look Loud Day - visit http://www.lookloud.org.uk to find out all about it. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re[2]: [xsl] simple method for list, klaus e. werner | Thread | [xsl] Elements with Mixed contents, Sandeep Deshpande |
RE: [xsl] alternate row color in a , Sébastien Tisserant | Date | Re: [xsl] alternate row color in a , Sébastien Tisserant |
Month |