xsl-list
[Top] [All Lists]

[xsl] Tokenize followed by compare or satisfies using contains()?

2016-09-02 11:04:03
In the DITA processing code, where we are using XSLT 2 and checking for
string matches in attribute values, I have the requirement to see if any
of a number of strings might match.

The current code is:

some $c in $link-classes satisfies contains($node/@class, $c))

Where $link-classes is a sequence of strings and @class is a
blank-delimited sequence of strings.


Another way to do this check would be:

$link-classes = tokenize($node/@class, ' ')

This is a check that will be made a lot so performance may important (or
it may not be). The tokenize version seems simpler and clearer to me but
the satisfies approach has a certain elegance that I also like.

My question: is there any reason to prefer one or the other of these? I
realize that XSLT 3 provides a new way to do token matching in strings but
for now we're stuff with XSLT 2.

Cheers,

Eliot
--
Eliot Kimber
http://contrext.com
 



--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>