This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Check if element is empty Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Check if element is empty" Watch "Check if element is empty" New topic
Author

Check if element is empty

Nils Persson
Greenhorn

Joined: May 25, 2001
Posts: 21
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

Joined: Jan 07, 1999
Posts: 6920
Using <xsl:if test="name"> tests if the named element is present, so <xsl:if test="not(name)"> should test for its absence.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
Check this: http://www.dpawson.co.uk/xsl/sect2/N3328.html#d121e60

Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
Vikram Das
Greenhorn

Joined: Jun 18, 2001
Posts: 6
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Check if element is empty
 
Similar Threads
Drag and Drop using jQuery
Can Empty Element contain child nodes?
onblur javascript error
Checking Multiple Variables for One Condition
Migration from WL10.1 to WL10.3 [Descriptor not found: META-INF/annotation-manifest.xml]