[Bug 10555] Pattern matching proposal for XQuery

http://www.w3.org/Bugs/Public/show_bug.cgi?id=10555





--- Comment #4 from Pavel Minaev <int19h@gmail.com>  2010-09-06 20:00:52 ---
I think it's a very neat twist, actually. I can think of quite a few cases from
past experience where the ability to do a simple check against a pattern would
be handy; in my original proposal, this is possible with a two-branch "match",
but overly verbose. In contrast, the [|pattern|] syntax is nicely composable,
especially if added as another option to FilterExpr, so that it can be used in
paths in lieu of [], like so:

    $nodes[|foo//bar|]/baz

So it wouldn't really be a boolean expression then, but you could combine it
with exists(), or just rely on effective boolean value, to get the desired
effect:

    if ($node[|foo//bar|]) then ...

And then, as Michael notes, you could still have "match", just require case
expressions to be pattern expressions (on grammar level):

    match ($node)
    case [|foo|] return 1
    case [|foo/bar|] return 2
    case [|*[@baz]//text()|] return 3
    default return 4

Aesthetically, it also has a nice look to it that blends well with the use of |
in patterns:

    $nodes[|foo|bar|baz|]

-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

Received on Monday, 6 September 2010 20:00:54 UTC