checking for an Null element
<image><a><img src="abcd"/></a></image>
XSLT template:
<xsl:if test="image!=''">
IMAGE HAS TEXT OR INNER ELEMENT
</xsl:if>
I am getting blank output though the “image” element has child elements. and Ideally it is not null.
I have to check the condition that it should have value or the child elements. The child elements can be empty.
How to rectify this.
Thank you
Use:
This evaluates to
true()only if there is at least oneimagechild of the current node, such that its string value is non-empty, or it has children (or both).This can be simplified just to:
taking into account that in order to have string value, an element must have a text node descendant in its sub-tree.
If you want the string value of
image(if any) to be not all-whitespace, modify the first of the above XPath expressions to: