[xquery-talk] contains(), matches(), highlight-matches()
mike at saxonica.com
Sat Jul 6 15:01:24 PDT 2013
Saxon's attempt at introducing analyze-string into XQuery (predating the XPath 3.0 fn:analyze-string) used higher order functions directly:
This in a sense is a much more direct equivalent of XSLT's xsl:analyze-string instruction than the version we ended up with in XPath 3.0.
But I think there are many use cases where the approach used by the XPath 3.0 fn:analyze-string, of generating XML markup representing the regex match structure, works well for many use cases. In particular, it can readily capture the subgroups matched by the regex, which is only done in a very clumsy way in the saxon:analyze-string() design.
On 6 Jul 2013, at 06:17, Joe Wicentowski wrote:
> Hi all,
> Today I posted some code  with a function for highlighting regex
> matches in an XML node. I'd appreciate any comments or improvements
> to the code (via response here, pull requests, or whatever method is
> best for you).
> I also wrote an accompanying post  for relative beginners to
> XQuery. While seasoned programmers probably come up this function on
> the first day they learn XQuery, I think it's beyond most
> XQuery-first-programmers like I was when I began. Yet I think the
> function is so basic that in my post I ventured to call it XQuery's
> "missing third function" - the first two being contains() and
> I'm curious: Was a function like this impossible to write in pure
> XQuery before 3.0's support for fn:analyze-string() and higher order
> functions? Surely, if it had been possible, it would've been in the
> functx library.
> Thanks in advance for your insights,
> Joe (@joewiz on twitter)
>  https://gist.github.com/joewiz/5937897
>  http://joewiz.tumblr.com/post/54729725793/xquerys-missing-third-function
> talk at x-query.com
More information about the talk