[Home] [By Thread] [By Date] [Recent Entries]
On 07/05/2010 13:28, Mukul Gandhi wrote:
As you said, many XSLT programming situations could be equivanetly handled by for-each& apply-templates. Not "many", all uses of for-each can be equivalently handled by apply-templates. .. <xsl:variable name="a">...</xsl:variable> .. <xsl:variable name="z">...</xsl:variable> ... <xsl:for-each select="foo"> body </xsl:for-each> is . <xsl:variable name="a">...</xsl:variable> .. <xsl:variable name="z">...</xsl:variable> ... <xsl:apply-templates select="foo" mode="unique-d"> <xsl:with-param name="a" select="$a"/> <xsl:with-param name="z" select="$z"/> </xsl:apply-templates> ... <xsl:template match="/|node()" mode="unique-id"> <xsl:param name="a"/> <xsl:param name="z"/> body </xsl:template> so xsl:for-each is just really a minor syntactic variation on apply-templates for a mode with only one template, in that you can inline the template body into the call. If the body uses variable references then you need to use parameters in the apply-template version to keep them in scope, but it's a purely syntactic transformation. David
This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. ________________________________________________________________________
|

Cart



