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

Re: Managing Generation of Output Filenames

Subject: Re: Managing Generation of Output Filenames
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 7 Feb 2002 15:52:48 +0000
xslt output filename
Hi Eliot,

> The challenge we're running into is we'd like to have a single chunk
> of code for generating the filenames, which have to go into both
> xsl:document tags and into hrefs used to create navigation links and
> authored cross references. We can't see any way to do this in XSL
> without writing an extension function.

What's wrong with making a single template, like:

<xsl:template name="generateFilename">
  ...
</xsl:template>

And then whenever you need the filename, put it in a variable:

  <xsl:variable name="filename">
    <xsl:call-template name="generateFilename" />
  </xsl:variable>

And then use the value of that variable in the href attribute using
attribute value templates:

  <a href="{$filename}">...</a>
  <xsl:document href="{$filename}">
    ...
  </xsl:document>

---

Or, since you're not using XSLT 1.0 anyway, why not move to XSLT 2.0
(Saxon 7.0) where you don't need to be so concerned about writing
extension functions, since they're all written in XSLT anyway. Just
write the filename-generating code in an xsl:function declaration:

<xsl:function name="my:generateFilename">
  ...
</xsl:function>

And call the function from the two attribute value templates:

  <a href="{my:generateFilename()}">...</a>
  <xsl:result-document href="{my:generateFilename()}">
    ...
  </xsl:result-document>

[If possible it'd be more efficient to go through a shared variable;
I'm just demonstrating that you don't have to.]

Am I missing some complication?
  
Cheers,

Jeni

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


 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.