XSLT 2.0 test tokenized results for no value

穿精又带淫゛_ 提交于 2019-12-25 03:34:09

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!