Subject: Re: [xsl] Processing mutiple files in multiple directories individually From: "Tony Graham" <Tony.Graham@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 18 Mar 2011 10:01:04 -0000 (GMT) |
On Fri, March 18, 2011 12:00 am, Mark wrote: > I am using XSLT 2.0. > > I have several hundred XML data files stored in a number of directories > each > with subdirectories of their own that descend to various levels. From > them, > I need to locate 137 specific files and make editing changes to each. I > believe I can write the template that can determine if a specific XML file > requires editing or not, and if so to then apply the editing change. > > What I do not know how to do is: > > (1) search through all the directories and subdirectories and open each > XML > file one at a time, If you're using Saxon, Saxon's collection() implementation [1] can recurse through subdirectories. > (2) if the file does not require editing, drop it and move on to the next > file; or That's a bit tougher to do with only XSLT. You could, as others have said, traverse through the files to produce a list of files to process in a second transformation or a second pass or you could apply an identity transform on the other files such that every file gets processed one way or the other. > (3) if the file requires editing, make the editing change and write the > file > out to its original location. I don't expect that to be possible. What if the XSLT processor opens the file for output before it's finished reading it as input? You could, as Liam said, write the files to another location and copy them over the originals after the XSLT has been run. Regards, Tony Graham Tony.Graham@xxxxxxxxxxxxxxxxxxxxxx Director W3C XSL FO SG Invited Expert Menteith Consulting Ltd XML Guild member XML, XSL and XSLT consulting, programming and training Registered Office: 13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland Registered in Ireland - No. 428599 http://www.menteithconsulting.com -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- xmlroff XSL Formatter http://xmlroff.org xslide Emacs mode http://www.menteith.com/wiki/xslide Unicode: A Primer urn:isbn:0-7645-4625-2 [1] http://www.saxonica.com/documentation/sourcedocs/collections.xml
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Processing mutiple files , Mark | Thread | Re: [xsl] Processing mutiple files , Mark |
Re: [xsl] Why namespace-alias resul, David Carlisle | Date | Re: [xsl] Processing mutiple files , Mark |
Month |