Xslt 1.0 check if something exists or empty value?

1.5k views Asked by At

Hi I am wondering is there any function in XSLT 1.0 and XPath 1.0 to behave like java's Appache StringUtils.isBlank(String str)

I use: Edited:

<xsl:variable name="attributeNameValue" select="$sourceObject/attr[@name = $sourceName]" />   
<xsl:if test="$attributeNameValue and not($attributeNameValue='')">
   <!-- Do something-->
</xsl:if>

but I have this check over 100 in all my templates and wonder how to remove it with something faster?

1

There are 1 answers

7
Martin Honnen On

In XPath/XSLT a common check is not(normalize-space($foo)) to check that $foo is an empty string or a pure white space string.