XML information pipe

Ihre Spezialisten für XML

Banner Werbung

XSLT 1.0 reference

apply-templates

Example 1 | Example 2 | Example 3 | Example 4 | Example 5 | Example 6 | Example 7 | Example 8 | Example 9 | Example 10 |


Example 2:


XML source: <AAA>
   <BBB>10</BBB>
   <BBB>5</BBB>
   <BBB>7</BBB>
</AAA>
XSLT stylesheet: <xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:output
indent="yes"
method="xml">

<xsl:template match="/">
<AAA>
   <xsl:apply-templates select="//BBB"/>
   <xsl:apply-templates mode="xxx" select="//BBB"/>
   <xsl:apply-templates mode="yyy" select="//BBB"/>
   </AAA>
</xsl:template>

<xsl:template match="BBB">
   <OOO>
   <xsl:value-of select="."/>
   </OOO>
</xsl:template>

<xsl:template match="BBB" mode="xxx">
   <XXX>
   <xsl:value-of select="."/>
   </XXX>
</xsl:template>

<xsl:template match="BBB" mode="yyy">
   <YYY>
   <xsl:value-of select="."/>
   </YYY>
</xsl:template>

</xsl:stylesheet>
Output: <AAA>
   <OOO>10</OOO>
   <OOO>5</OOO>
   <OOO>7</OOO>
   <XXX>10</XXX>
   <XXX>5</XXX>
   <XXX>7</XXX>
   <YYY>10</YYY>
   <YYY>5</YYY>
   <YYY>7</YYY>
</AAA>
Back