jbrehr
jbrehr

Reputation: 815

XSLT 2.0 test tokenized results for no value

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?

Upvotes: 0

Views: 248

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167571

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.

Upvotes: 1

Related Questions