Re: [xsl] XSLT: question re testing for possibly empty elements

Subject: Re: [xsl] XSLT: question re testing for possibly empty elements
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 17 Aug 2004 10:05:14 +0100
  test="string-length(anElement) &gt; 0">

that is the same as 

  test="string-length(anElement)">


and tests if the string length is non zero

so <anElement/> and <anElement><x/><y/></anElement> are both false and
<anElement>z</anElement> is true


  But couldn't you rewrite that as

  <xsl:when test="anElement">

No that tests if teh element is there so all the 
so <anElement/>  <anElement><x/><y/></anElement>  and
<anElement>z</anElement> are all true

Probably intended meaning is


  test="anElement/node()">


which tests if the element has children so

so <anElement/> is false and a<anElement><x/><y/></anElement> and <anElement>z</anElement> are true

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread