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

Re: check if a node is empty

Subject: Re: check if a node is empty
From: jeremyf@xxxxxxxxxxx
Date: Thu, 17 Oct 2002 10:49:01 -0400
xsl check node empty
Jeni,
      Thank you. That worked a treat! I said it would be something so
simple....
      Thanks for your rapid response to my question.

Jeremy





Hi jeremyf,

> I have an XML document that may contain nodes with no children
>
>       <node>
>       </node>

That's an element called 'node' with a single text node child (the
text node is just whitespace, but it still counts as a text node
unless you're stripping spaces?).

> I need to test if this is the case in my XSL in order to output the
> correct information

I suspect that you want to test whether the 'node' element contains
any element children, in which case the test should be:

<xsl:template match="node">
      <xsl:choose>
            <xsl:when test="*">
                  'node' element has child elements
            </xsl:when>
            <xsl:otherwise>
                  'node' element doesn't have child elements
            </xsl:otherwise>
      </xsl:choose>
</xsl:template>

But you might mean any one of:

  test="node()"                 -- any child nodes
  test="* or text()"            -- any element or text children
  test="* or normalize-space()" -- any element or text aside from
                                   whitespace

I hope that one of those fulfills your requirements.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/







 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.