I've got an XML file with this structure:
<entry id="1">
<para>first paragraph</para>
<para>second paragraph</para>
</entry>
<entry id="2">
<para></para>
</entry>
My XSL needs to do something if it finds an entry has a first element whose text node is empty (entry id="2" in the example). I've tried this:
<xsl:when test="(entry/para[1]/text()='')">
but that doesn't seem to work.
A similar code snippet to read an attribute of the element does work:
<xsl:when test="entry[1]/para[@stylename = 'Table Heading']">
So I'm doing something wrong with the text()='' selection. A search suggests I should use [not(text())] but I can't figure out how to integrate this in my code.
text()=''
requires a text node to be there, but in the case of <para></para>
, there is no text node to be matched.
So, I'd suggest something like
entry/para[1][.='']
or
entry/para[1][not(text())]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With