W3C home > Mailing lists > Public > public-qt-comments@w3.org > August 2004

RE: appeal for fn:match and fn:apply

From: Mark D. Anderson <mda@discerning.com>
Date: Mon, 16 Aug 2004 16:28:18 -0700
To: public-qt-comments@w3.org
Message-Id: <1092698898.26771.202453988@webmail.messagingengine.com>

> The main difference is that there is no equivalent of
> xsl:non-matching-substring.
> How would you translate
> <name>John F. /Kennedy/</name>
> to
> <name>John F. <surname>Kennedy</surname></name>

I wouldn't do it that way. If I want to use something in the
input, I'll capture it. In years of Perl programming I've
never confronted a need for this notion of "capturing things
I'm not capturing".

The only case I can think of is when I'm splitting a string
and want to retain the matching delimeter substrings too;
this is possible in perl split() by putting capturing parens
in the delimeter regexp. [I might note that this is sadly
*not* supported by fn:tokenize, which always discards the

So anyhow:

  let $parts := fn:match($orig, "(.*?)/(.*?)/")
  return <name>{$parts[1]}<surname>{$parts[2]}</surname></name>

Or, if XQuery were to adopt $N references within the lexical scope
of a fn:matches:

   if (fn:matches($orig, "(.*?)/(.*?)/")) then

Incidentally, if I don't mind committing to an excluded character,
it is sort of possible to emulate fn:match by:

  (: for the case of 2 captures, and ',' never appearing in the captured
  substring :)
  fn:tokenize(fn:replace($input, $pattern, "$1,$2"), ',')

Which to me has a hoop-jumping feel reminiscent of XSLT 1.0...

Received on Monday, 16 August 2004 23:28:35 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:45:20 UTC