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

[xsl] Nicer way to change context-node than xsl:for-each ?


Subject: [xsl] Nicer way to change context-node than xsl:for-each ?
From: Frédéric Schwebel <Fred.Schwebel@xxxxxxxxxxx>
Date: Fri, 4 Dec 2009 15:25:12 +0100

Hi folks,

In a template I want to change the context node to the first child.
Here's the workaround I've found :

<xsl:template match="foo">
  <!-- do things with root -->
  <xsl:for-each select="*[1]">
    <xsl:value-of select="." />
    <!-- do many other things, call templates... -->
  </xsl:for-each>
</xsl:template>

Usually xsl:for-each is used to process a serie of nodes, not only to
change the context. I know I should do an apply-templates and the
corresponding template-match, but that would mean rewrite the entire
xsl so I can't do it (for now).

This solution is ok, but if something like "xsl:with" or "xsl:context"
exists, I'd be glad to know.

Thanks for any help,
Regards
Frederic


Current Thread
Keywords
xsl