|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Empty elements
Playing with Mike Kays definition of empty elements,
http://sources.redhat.com/ml/xsl-list/2000-09/msg00598.html
<doc>
<node id="@id00"/>
<node id="id1"> </node>
<node id="id02"><!--comment--></node>
<node id="id03"><x/></node>
</doc>
<xsl:template match="node">
<xsl:call-template name="mt"/>
</xsl:template>
<xsl:template name="mt">
<xsl:choose>
<xsl:when test="not(string(.))">
Node: <xsl:value-of select="@id"/> is empty using string(.)&nl;
</xsl:when>
<xsl:when test="string(.)">
Node: <xsl:value-of select="@id"/> is not empty using string(.)&nl;
</xsl:when>
<xsl:otherwise>
Otherwise 1 reached on <xsl:value-of select="@id"/> .&nl;
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="not(node())">
Node: <xsl:value-of select="@id"/> has no children &nl;
</xsl:when>
<xsl:when test="node()">
Node: <xsl:value-of select="@id"/> has children &nl;
</xsl:when>
<xsl:otherwise>
Otherwise 2 reached on <xsl:value-of select="@id"/> .&nl;
</xsl:otherwise>
</xsl:choose>
</xsl:template>
gives
Node: @id00 is empty using string(.)
Node: @id00 has no children
Node: id1 is not empty using string(.)
Node: id1 has children
Node: id02 is empty using string(.)
Node: id02 has children
Node: id03 is empty using string(.)
Node: id03 has children
Interesting, and quite informative.
(I'll be using this one :-)
Regards DaveP
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








