Testing for missing attributes in XML elements is different from testing for attributes with empty values. You can test for missing attributes with <xsl:if test="not(@attribute)">, but this test will never succeed if the attribute is present but empty. In that case, you have to use the <xsl:if test="@attribute = ''"> condition.
This post is part of You've asked for it series of articles.
4 comments:
then how to you check if the attribute value is not emtpy
like this maybe
xsl:if test="@attribute != ''"
Absolutely right.
Forgive me if I'm wrong, I'm new to xslt but LiquidXml editor does not work with your example above - testing for a missing attribute. This is what I got to work:
<xsl:if test="not(@attribute)">
Apparently "not" is a function and needs the parenthesis to work right.
You're correct. Fixed the post.
Post a Comment