[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Empty elements

Subject: Empty elements
From: "Pawson, David" <DPawson@xxxxxxxxxxx>
Date: Wed, 20 Sep 2000 16:39:46 +0100
kays definition
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.