Altova Mailing List Archives


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

From: Jeni Tennison <jeni@---------------->
To:
Date: 8/28/2002 1:13:00 AM
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

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.