After my close encounter with ternary logic of XSLT (details are here), I started worrying about the results of every test that could contain empty elements (based on how you phrase the test, the empty string might not be equal to empty node-set). To ensure that I’m comparing strings even when one of the variables might be empty, I’m using the string XSLT function that converts whatever input it gets into a string (which can be reliably compared to another string). For example, to test if the current element’s name is empty or missing, use this test:
<xsl:if test="string(@name) = '' ">
No comments:
Post a Comment