Name
<xsl:if>
Synopsis
<xsl:if test="
pattern
" >...</xsl:if>
Description
You can use the <xsl:if>
conditional to select a specific
element while inside a template. The <xsl:if>
element uses
the test
attribute to determine which elements should be
selected. The test
attribute takes a standard pattern matching
string. For example:
<xsl:template match="chapter/title" > <xsl:apply-templates/> <xsl:if test=".not([last-of-type()])">, </xsl:if> </xsl:template>
This template matches each of the qualifying <title>
elements, but inserts commas after those that are not the
last <title>
element. The result is a standard comma-separated
list.
Get Webmaster in a Nutshell, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.