Tuesday, 15 May 2012

xslt - XSL: match two template with same XPath-expression but different code inside other template -



xslt - XSL: match two template with same XPath-expression but different code inside other template -

i know, can phone call xsl:apply-templates within template, when specify xpath-expression of subtemplate.

in xsl-file got an

<xsl:template match="/"> <xsl:apply-templates select="root/values" /> </xsl:template> <xsl:template match="root/values> <xsl:value-of select="value/key" /> </xsl:template>

now want subnodes of root/values 1 time again in context - how match template in main template?

<xsl:template match="root/values> <xsl:for-each select="value"> <xsl:value-of select="key" /> </xsl:for-each> </xsl:template>

i think want utilize mode:

<xsl:template match="/"> <xsl:apply-templates select="root/values" /> <xsl:apply-templates select="root/values" mode="m1" /> </xsl:template> <xsl:template match="root/values> <xsl:value-of select="value/key" /> </xsl:template> <xsl:template match="root/values" mode="m1"> <xsl:for-each select="value"> <xsl:value-of select="key" /> </xsl:for-each> </xsl:template>

templates xslt xpath xslt-2.0

No comments:

Post a Comment