[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Managing Generation of Output Filenames
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|