If xsl:apply-templates element without select attribute is used, the value of implicit select is set to "node()". It means that all children nodes are selected.
|
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="/*"> <xsl:apply-templates/> </xsl:template> <xsl:template match="text()"> <text> <xsl:value-of select="normalize-space(.)"/> </text> </xsl:template> <xsl:template match="comment()"> <comment> <xsl:value-of select="normalize-space(.)"/> </comment> </xsl:template> <xsl:template match="@*"> <attribute> <xsl:value-of select="."/> </attribute> </xsl:template> <xsl:template match="*"> <element> <xsl:value-of select="name()"/> </element> </xsl:template> </xsl:stylesheet> |
|
|
XML
<aaa a="1"> BBB <ccc/> DDD <!-- comment --> </aaa> |
Output
<text>BBB</text> <element>ccc</element> <text>DDD</text> <comment>comment</comment> <text/> |
| Previous chapter: | Context |
| Next chapter: | Arithmetics |
| Previous page: | - - - |
| Next page: | xsl:apply-templates without select attribute and position |