Accessing the match pattern in XLS tokenize
Suppose I have the following variable
<xsl:variable name="randomString" select="'COLUMN1 == 400 or COLUMN1 == 5 and COLUMN2 != 3'" />
Is there a convenient way to access the matched pattern in the tokenize () function, e.g. using this
<xsl:for-each select="tokenize($randomString, 'and|or')">
<xsl:value-of select="concat('not(', current(), ')')" />
<!-- How do I access the matched pattern? -->
</xsl:for-each>
Or do I need to use a custom template like the one I found here http://docbook.sourceforge.net/release/xsl/1.77.0/doc/lib/str.tokenize.keep.delimiters.html
source to share
No, there is no way to get the matched delimiter. "Separators don't come back on their own." ( http://www.w3.org/TR/xpath-functions/#func-tokenize )
A workaround could be meaning or
like a delimiter in the outer loop, and then tokenization using and
like delimiter in the inner loop. Then you will always know which delimiters you are facing based on where you are in the loops.
Another approach would be to use analyze-string()
. See this answer .
source to share