I have a document type with a textstring field that is left empty. Testing if the field is equal to an empty string doesn't work in an XSLT macro. I need to test if the field is false.
xsl:if test="$node/field != ''" doesn't work.
xsl:if test="$node/field" works.
Strange thing is that in the live environment the first test actually works as well. The only difference is that the live environment runs 4.7.1 and the dev environment runs 4.7.1.1.
Given that it seems to work inconsistently, what is the preferred way to check if a field is empty?
How to test if a field is left empty?
I have a document type with a textstring field that is left empty. Testing if the field is equal to an empty string doesn't work in an XSLT macro. I need to test if the field is false.
xsl:if test="$node/field != ''" doesn't work.
xsl:if test="$node/field" works.
Strange thing is that in the live environment the first test actually works as well. The only difference is that the live environment runs 4.7.1 and the dev environment runs 4.7.1.1.
Given that it seems to work inconsistently, what is the preferred way to check if a field is empty?
Hi Michiel,
I usually go with a "normalize-space" check:
This will return true if the 'field' exists and is non-empty/non-whitespace.
Cheers, Lee.
is working on a reply...