[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] xslt processing XML file by applying multiple transformation


Subject: RE: [xsl] xslt processing XML file by applying multiple transformation
From: "Mark Lundquist" <ml@xxxxxxxxxxxxxx>
Date: Tue, 11 Jan 2005 20:41:10 -0800

> Hello,
> I have an XML document that i need to transform into
> another XML document. To do that, I need to first
> tranform the original XML document using one xsl file.
> The the output XML generated in the first translation,
> I need to again transform it to another XML using a
> second xsl file.
> 
> If possible, I want to do this by using a single xsl
> file where i would somehow do the first translation
> and then pass the whole result document throught a
> second translation.

u betcha!  In XSLT 2.0:

	<xsl:template mode="pass1" match="/">
		.
		.
	</xsl:template>

	<xsl:template mode="pass2" match="/">
		.
		.
	</xsl:template>

	<xsl:variable name="pass1-result">
	   <xsl:apply-templates mode="pass1" select="/" />
	</xsl:variable>

	<xsl:template match="/">
	   <!-- see note below -->
	   <xsl:apply-templates
		   mode="pass2"
		   select="$pass1-result"
	</xsl:template>

In XLST 1.0, the select attribute would be

	select="exslt:node-set($pass1-result)"

where

	xmlns:exslt="http://exlst.org/common"

HTH,
- mark


Current Thread
Keywords