• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Check if element is empty

 
Nils Persson
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to check if an element is empty (or = 0). How do I do that?
Can I use <xsl:if test=???>?
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using <xsl:if test="name"> tests if the named element is present, so <xsl:if test="not(name)"> should test for its absence.
 
Mapraputa Is
Leverager of our synergies
Sheriff
Posts: 10065
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check this: http://www.dpawson.co.uk/xsl/sect2/N3328.html#d121e60
 
Vikram Das
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nils,
If you wanna chk whether the tag is empty (as in this case <tag></tag> ) or whether the tag is not there at all ... you can use a generic thing which will do both of it ... Assuming that the tag is <name>, you can use the xsl given below to do this,
<xsl:if test="count(name/text()) != 0">
Hope this helps...
Vicks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic