Mode "#current" is useful when it is used in a shared template. It sets the value of xsl:apply-templates to the mode in which the ancestor xsl:template was called.
|
XSLT
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/> <xsl:template match="/aaa"> <xsl:apply-templates mode="m1"/> <xsl:apply-templates mode="m2"/> <xsl:apply-templates mode="m3"/> <xsl:apply-templates mode="m4"/> </xsl:template> <xsl:template match="bbb" mode="m1 m3 m4"> <bbb-1-3-4> <xsl:apply-templates select="ccc" mode="#current"/> </bbb-1-3-4> </xsl:template> <xsl:template match="bbb" mode="m2"> <bbb-2> <xsl:apply-templates select="ccc" mode="#current"/> </bbb-2> </xsl:template> <xsl:template match="ccc" mode="m1"> <ccc-1/> </xsl:template> <xsl:template match="ccc" mode="m2"> <ccc-2/> </xsl:template> <xsl:template match="ccc" mode="m3"> <ccc-3/> </xsl:template> <xsl:template match="ccc" mode="m4"> <ccc-4/> </xsl:template> </xsl:stylesheet> |
|
|
XML
<aaa> <bbb> <ccc/> </bbb> </aaa> |
Output
<bbb-1-3-4> <ccc-1/> </bbb-1-3-4> <bbb-2> <ccc-2/> </bbb-2> <bbb-1-3-4> <ccc-3/> </bbb-1-3-4> <bbb-1-3-4> <ccc-4/> </bbb-1-3-4> |
| Previous chapter: | Value-of |
| Next chapter: | Context |
| Previous page: | Mode: #current |
| Next page: | - - - |