Re: [xsl] Returning the file name of the input file

Subject: Re: [xsl] Returning the file name of the input file
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 28 Aug 2002 10:14:38 +0100
Hi Ismael,

> That would be a possibility if I only have to transform one file.
> But what I use now is an xml file that refers to other xml files.
> With the document() function I traverse all these xml files. By
> passing a parameter to the source file I have only the name of one
> file. What I want is the name for each xml file I traverse ... I
> don't think I can do this with passing parameters ...

You should be able to do it by passing parameters *between templates*
in that case, or even that might not be necessary. If you've got the
name of the file because you're opening it through the document()
function then surely you've got the name of the file in order to
create it in the output. (I'm assuming you're using an extension
element such as saxon:output to create the output files.) Something
like:

<xsl:template match="file">
  <xsl:variable name="href" select="@href" />
  <saxon:output href="{$href}">
    <xsl:apply-templates select="document($href, .)" mode="process" />
  </saxon:output>
</xsl:template>

I'll note that it's probably a bad idea to read and write to/from the
same file -- if something goes wrong during the transformation you'll
probably end up losing all your data...

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


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


Current Thread