[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Processing mutiple files in multiple directories

Subject: Re: Processing mutiple files in multiple directories individually
From: "Mark" <mark@xxxxxxxxxxxx>
Date: Fri, 18 Mar 2011 06:04:41 -0700
Re:  Processing mutiple files in multiple directories
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: 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.