[thelist] XSL question

Mark Kennedy mark at eurogamer.net
Wed Mar 12 05:18:15 CST 2003


With XSLT1.1 you can output to a temporary tree and then use this variable as
the input to another template.  Here's a cut down example I dug out of Michael
Kay's XSLT 2nd Edition (very comprehensive book IMO):

<xsl:template match="/">
	<xsl:variable name="phase1output">
		<xsl:apply-templates select="." mode="phase1" />
	</xsl:variable>
	<xsl:apply-templates select="$phase1output" mode="phase2" />
</xsl:template>

Hope that helps.  XSL is a monster sometimes!

Mark


On Tue, 11 Mar 2003 David.Cantrell at Gunter.AF.mil wrote:

>OK, I don't think this is really possible but I wanted to toss it out just
>in case I'm wrong.
>
>Does anybody know if you can, in a single stylesheet, take the results of a
>template (named) and pipe that template's output into another template?
>
>I want to run an XSLT file against other XSLT files and extract information
>from them. I also want to separate the processing from the display, so in
>effect I want a pre-processor that extracts the information, and then
>another processor which applies the format.
>
>Something like this is what I'm looking for:
>
>	<xsl:template name="preprocess">
>		<xsl:for-each select="/">
>			<doc>
>				<foo><xsl:value-of
>select="/xsl:stylesheet/foo"/></foo>
>				<bar><xsl:value-of
>select="/xsl:stylesheet/bar"/></bar>
>		</xsl:for-each>
>	</xsl:template>
>
>	<xsl:template name="display">
>		<p><var>Foo</var> = <xsl:value-of select="/doc/foo"/></p>
>		<p><var>Bar</bar> = <xsl:value-of select="/doc/bar"/></p>
>	</xsl:template>
>
>What I'm missing is the way to tie the "preprocess" template's results into
>the "display" template's input. I don't think you can do that, because I
>believe the XSL functions such that each template writes to a single output
>stream. Would be nice if you could control that somehow though...
>
>Basically this is reflection on a stylesheet. If I have to break the two up
>into separate stylesheets and <xsl:import> the pre-processor in, that's
>fine, but I really (really really really) want to keep the actual
>transformation contained so I can look at an XSL file in Internet Explorer
>and it will do the transform for me automatically. If I have to write any
>code to do this, it really defeats the purpose of this whole approach.
>
>Maybe there's a better way to do this?
>
>Thanks!
>-dave
>

 



More information about the thelist mailing list