I need to check if an XML node has at least one non-empty child. Applied to this XML the expression should return true
Here's one XPath that should accomplish the job:
count(/*/node/*[text()]) > 0
When used in a sample XSLT:
...which is, in turn, applied to the provided example XML:
value
...the expected result is produced:
true
If we apply the same XSLT against a simply modified XML:
...again, the expected result is produced:
false
Explanation:
The XPath used searches for all children of a
element (which are, in turn, children of the root element) that have a non-empty text value (as specified by text()
); should the count of such
children be greater than 0, then the XPath resolves to true
.