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

Re: document() revisited

Subject: Re: document() revisited
From: Steve Tinney <stinney@xxxxxxxxxxxxx>
Date: Wed, 16 Feb 2000 08:29:52 -0500
Re: document() revisited
> <mother>
>   <file>files\overview.html</file>
>   <file>files\book1\page1.html</file>
>   <file>files\book1\chap1\page2.html</file>
>   <file>files\book2\page1.html</file>
>   <file>files\book2\chap1\page2.html</file>
> </mother>
> 
> How can I use XSL to enter each listed file,
> manipulate it and copy the result onto itself,
> thus retaining the file names and directory structure?

You would need to use document(), as you already realize, in conjunction
with a processor that has at least an output extension, and possibly a
nodeset extension also (depending on what you want to do).  You would
need to be sure that after a document() call, the processor closed the
file (i.e., do some testing with unimportant data first or, better, read
the source for your processor).  So, the structure would be something
like this:

    <xsl:template match="file">
      <xsl:variable name="pathname" select="."/>
      <xsl:variable name="contents" select="document($pathname)"/>
      <xsl:variable name="newcontents-rtf">
        ... rewrite $contents here ...
      </xsl:variable>
      ... possibly do further transforms here ...
      <saxon:output file="$pathname" method="xml" encoding="utf-8">
        <xsl:copy-of select="$newcontents-rtf"/>
      </saxon:output>
    </xsl:template>

You probably need to ensure that you reference $contents before doing
the file open for the new output because most(? some?) processors do
lazy evaluation of the select expressions.

 Steve


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.