[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Hi Tony,
Yes, I misspoke when I said I wanted to overwrite the original. I should have said that I would eventually replace the original.
-----Original Message----- From: Tony Graham
Sent: Friday, March 18, 2011 3:01 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Processing mutiple files in multiple directories individually
On Fri, March 18, 2011 12:00 am, Mark wrote:
That's a bit tougher to do with only XSLT.
Regards,
[1] http://www.saxonica.com/documentation/sourcedocs/collections.xml
Re: [xsl] Processing mutiple files in multiple directories individually
Subject: Re: [xsl] Processing mutiple files in multiple directories individually From: "Mark" <mark@xxxxxxxxxxxx> Date: Fri, 18 Mar 2011 06:04:41 -0700 |
Hi Tony,
Yes, I misspoke when I said I wanted to overwrite the original. I should have said that I would eventually replace the original.
Thanks again to everyone, you've given me a lot to think about. Mark
-----Original Message----- From: Tony Graham
Sent: Friday, March 18, 2011 3:01 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Processing mutiple files in multiple directories individually
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 , Tony Graham | Thread | [xsl] Why namespace-alias result pr, Karl Stubsjoen |
Re: [xsl] Processing mutiple files , Mark | Date | Re: [xsl] Date and Time of a File, Florent Georges |
Month |