On Mon, Jun 29, 2009 at 12:15 PM, Marcus Downing<
marcus@...> wrote:
>
> Like XML itself, XPath is a standard. An implementation that lets programmers
> from other languages use their existing knowledge without modification is
> better than one that's idiomatically Scalaish. Something like this:
>
> for (n <- library \ "//book[author/@id=234]") ...
I agree that supporting the standard is good, reuse of knowledge etc.
But, having done some more reading, I suspect Scala has made a
conscious, defensible choice to offer a different API.
AFAIK, the Scala XML rep is a singly-linked list. So, no parent refs
and cannot go backwards through tree. I see now that this means
supporting full XPath was probably not practical without converting to
a DOM rep.
Should Scala offer a XPath query method on Node, if only parts of the
standard are supported, and/or sometimes incur severe performance
costs?
Maybe it should, but make the options clear: High performance default
impl with only "XPath-like" \ & \\ operators, OR, full XPath query
which will force use of more memory hungry & less functional data rep?
-Ben
PS thanks Naftoli, Alex for pointers to <xml:group>