Empty elements

Subject: Empty elements
From: "Pawson, David" <DPawson@xxxxxxxxxxx>
Date: Wed, 20 Sep 2000 16:39:46 +0100
Playing with Mike Kays definition of empty elements,

<node id="@id00"/>
<node id="id1"> </node>
<node id="id02"><!--comment--></node>
<node id="id03"><x/></node>

<xsl:template match="node">
  <xsl:call-template name="mt"/>

<xsl:template name="mt">
  <xsl:when test="not(string(.))">
    Node: <xsl:value-of select="@id"/> is  empty using string(.)&nl;
  <xsl:when test="string(.)">
    Node: <xsl:value-of select="@id"/> is not empty using string(.)&nl;
  Otherwise 1 reached on  <xsl:value-of select="@id"/> .&nl;
  <xsl:when test="not(node())">
    Node: <xsl:value-of select="@id"/> has no children &nl;
  <xsl:when test="node()">
    Node: <xsl:value-of select="@id"/> has children &nl;
  Otherwise 2 reached on  <xsl:value-of select="@id"/> .&nl;

  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

Current Thread