- From: Mark D. Anderson <mda@discerning.com>
- Date: Mon, 16 Aug 2004 16:28:18 -0700
- To: public-qt-comments@w3.org
> 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 delimeters.] 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 <name>{$1}<surname>{$2}</surname></name> else () 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... -mda
Received on Monday, 16 August 2004 23:28:35 UTC