multiple next-in-chain branches
Added by Anonymous about 15 years ago
Legacy ID: #7836600 Legacy Poster: Tobias Klevenz (tklevenz)
Hi, is there a way to have 2 xsl:output elements each calling a different stylesheet with saxon:next-in-chain, and decide with a parameter which next-in-chain processing to use? First I thought about using the use-when attribute in xsl:output, but I guess I misunderstood how that is used. Then I tryed the following: stylesheet.xsl <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0"> <xsl:import href="stylesheet1.xsl"/> <xsl:import href="stylesheet2.xsl"/> <xsl:param name="output">style1</xsl:param> <xsl:template match="/"> xsl:choose <xsl:when test="$output='style1'"> <xsl:call-template name="stylesheet1"/> </xsl:when> xsl:otherwise <xsl:call-template name="stylesheet2"/> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> stylesheet1.xslt <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0" xmlns:saxon="http://saxon.sf.net/"> <xsl:output saxon:next-in-chain="stylesheet1-next.xsl"/> <xsl:template name="stylesheet1"> </xsl:template> </xsl:stylesheet> stylesheet2.xsl ...same as 1 just different next-in-chain But it seems to be kind of random which xsl:output-element from which imported stylesheet it uses. Thanks in advance, Tobias
Replies (2)
RE: multiple next-in-chain branches - Added by Anonymous about 15 years ago
Legacy ID: #7836856 Legacy Poster: Michael Kay (mhkay)
If there are several xsl:output elements, then each attribute is taken from the xsl:output element with highest import precedence, considering only those xsl:output elements on which the attribute is actually specified. If you want to compute xsl:output parameters dynamically, the way to do it is normally with xsl:result-document. This allows you either to compute most invidual serialization parameters at run-time (but unfortunately not saxon:next-in-chain), or to select one of a number of named xsl:output declarations. I think that what you're trying to achieve might be better achieved with an XProc pipeline. But another option, if you really want to control it from within the stylesheet, is to use the saxon:transform extension function.
RE: multiple next-in-chain branches - Added by Anonymous about 15 years ago
Legacy ID: #7837256 Legacy Poster: Tobias Klevenz (tklevenz)
Sadly XProc is not an option for the client I'm doing this at the moment. saxon:transform seems to much of a hazzle for a rather small problem I got here, so I guess I'll do it the old way and just write 2 different batch files. Thank you anyways, at least I've learned something new trying :) Tobias
Please register to reply