[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xsl-list
Subject:    Re: [xsl] Processing mutiple files in multiple directories      individually
From:       "Mark" <mark () knihtisk ! org>
Date:       2011-03-18 13:04:41
Message-ID: DA0FF5FDB9E748AB8C071C42D8642981 () BIGBOY
[Download RAW message or body]

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@lists.mulberrytech.com
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@MenteithConsulting.com
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@lists.mulberrytech.com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@lists.mulberrytech.com>
--~--

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic