问题
In XSLT 2.0 I am handling a string delimited by ~. There are times that the tokenized results contain an instance of 'nothing' between two ~. I try to test for this using empty()
<xsl:for-each select="tokenize($list_of_items,'~')">
<xsl:if test="not(empty(.))">
...do something here...
</xsl:if>
</xsl:for-each>
...which doesn't work. What is the correct way to test for nothing/empty/blank value in a tokenized list?
回答1:
tokenize gives you a sequence of strings, if you have an input with two adjacent separator characters (e.g. tokenize('foo~~bar', '~')) then you get an empty string so tokenize($list_of_items,'~')[not(. = '')] should do to exclude empty strings.
来源:https://stackoverflow.com/questions/53693719/xslt-2-0-test-tokenized-results-for-no-value