Hi Steffi,
XQuery is much more powerful than I was thinking about. My initial
vision is closer to XPath with some differences, such as pattern
matching in addition to path expressions and support for quantified
boolean expressions for dealing with repeated/optional fields. Also,
it should be based on Piq data model and syntax.
I'll give some simple examples:
1. Simple path expressions
foo.bar.baz % path composed of record labels
:mod/t.bar.baz % path starting with a type "mod/t" and continuing
with correspondent record labels
foo.bar:int % path ending with a leaf "int" type
2. Pattern matching
foo [ .bar [ .baz ]] % general form of ".foo.bar.baz" matching
expression
foo.bar [ .baz 10 ] % there is some baz field which equals 10 (in
general -- matches with 10).
Equivalent expressions: .foo.bar [ (some baz = 10)] and .foo.bar
[ (baz = 10) ]
foo.bar [ .baz 10 .some-inner-structure [ .some-field true ] ] %
pattern matching with inner patterns
foo [ (bar > 10 && fum = bar) ] % more complicated expression w/o
pattern matching
All the above examples are for matching (i.e. selection op). A lot of
features such as "return" (i.e. projection op) or boolean quantifiers
haven't been really designed yet. I didn't have enough time to think
about advanced features, but my approach would be to start
experimenting with selection based on path expressions and pattern
matching and add more complicated functionality later.
Piqi is written in OCaml which is probably the best tool for
implementing languages. Working with Piq types and intermediate data
representation using Piqi library is pretty straightforward and all
low-level lexers and parsers are already there.
Also, I know that Lucent has open-source XQuery implementation written
in OCaml called Galax. I haven't looked at it in depth, but if you're
interested specifically in XQuery, maybe it is possible to retarget
their XQuery engine to work on top of Piq/Protocol Buffers data.
Anton