<xslTutorial creator="nicmila@idoox.com">
<index keywords='xsl:if boolean() normalize-space()'/>

<description>Sometimes you want to output an element only if it has a value.
<stylesheet id='id2'/> shows a way how to do it. Function normalize-space removes unsignificant spaces. <stylesheet id='id3'/> shows the output without empty elements removal. 
</description>

<xmlSource id="id1">
<table>
<item> item 1 </item>
<item> item 2 </item>
<item></item>
<item>     </item>
<item> item           3</item>
</table>
</xmlSource>

<attValues>
<value match="">
</value>
</attValues>


<xslStylesheet id="id2">
<xsl:template match="table">
<TABLE BORDER='1'>
<xsl:for-each select="item">
<xsl:apply-templates select="."/>
</xsl:for-each>
</TABLE>
</xsl:template>

<xsl:template match="item">
<xsl:variable name="tmp"> <xsl:value-of select="."/></xsl:variable>
<xsl:if test="boolean(normalize-space($tmp))">
<TR><TD><xsl:value-of select="$tmp"/></TD></TR>
</xsl:if>
</xsl:template>
</xslStylesheet>

<xslStylesheet id="id3">
<xsl:template match="table">
<TABLE BORDER='1'>
<xsl:for-each select="item">
<xsl:apply-templates select="."/>
</xsl:for-each>
</TABLE>
</xsl:template>

<xsl:template match="item">
<TR><TD><xsl:value-of select="."/></TD></TR>
</xsl:template>

</xslStylesheet>
</xslTutorial>