• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Check if element is empty

 
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=???>?
 
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.
 
Leverager of our synergies
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
 
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.
 
And then we all jump out and yell "surprise! we got you this tiny ad!"
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic