- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
XPath in Scala
Tue, 2011-02-08, 13:35
More than two years ago, I expressed a wish for Scala's native XML to support XPath queries. Looking through the mailing lists and elsewhere, quite a few other people have asked for something similar. Is there any implementation, either out there or under way?
Tue, 2011-02-08, 15:17
#2
Re: XPath in Scala
Personally I like the Scala native XML support - with its current
limitations.
Ideally it could be extended to wrap up existing Java libraries (so that no DSL is needed) and fully support XPath *2*.
Robert.
Le 8/02/2011 14:48, Juergen Purtz a écrit :
Ideally it could be extended to wrap up existing Java libraries (so that no DSL is needed) and fully support XPath *2*.
Robert.
Le 8/02/2011 14:48, Juergen Purtz a écrit :
4D5149BA [dot] 8030601 [at] purtz [dot] de" type="cite"> Does it make sense to implement full XPath support to native Scala? Why not using one of the existing Java libraries? It's a hard job to develop a fully compliant solution.
The same question should be addressed to other necessaries in the XML environment: xsl, xslt, validation against a schema, DOM like API, ... .
As far as I know we have a native implementation for JAXB (that's great and necessary!) and our own data model (there is some criticism about the actual implementation).
My feeling is that we should have a DSL for XML processing, which acts as a layer to existing Java libraries.
Jürgen
On 08.02.2011 13:35, Marcus Downing wrote:More than two years ago, I expressed a wish for Scala's native XML to support XPath queries. Looking through the mailing lists and elsewhere, quite a few other people have asked for something similar. Is there any implementation, either out there or under way?
Tue, 2011-02-08, 15:27
#3
Re: XPath in Scala
Does it make sense to implement full XPath support to native Scala? Why not using one of the existing Java libraries? It's a hard job to develop a fully compliant solution.
I agree, if the Java library can be made to integrate with Scala's native XML. I really don't want to go back to the bad old days of verbose API calls to completely mutable data models. (yes, there are occasions when a judicious touch of mutability can help, but it's a long way removed from the old everything-is-mutable way of doing things).
Is there a way of hooking them together?
My feeling is that we should have a DSL for XML processing, which acts as a layer to existing Java libraries.
A DSL to ease the use of XPath, yes. An attempt to replicate XPath's functionality with method calls, infix operators, implicits, for comprehensions and special collection types, no - at least not exclusively. XPath is a standard, and it should be possible to copy-paste an XPath between all different languages and libraries. Ideally what I'd like to see is something like this:
val things = xml \ "/node[id=foo]//thing"
Jürgen
On 08.02.2011 13:35, Marcus Downing wrote:More than two years ago, I expressed a wish for Scala's native XML to support XPath queries. Looking through the mailing lists and elsewhere, quite a few other people have asked for something similar. Is there any implementation, either out there or under way?
Sun, 2011-04-03, 11:07
#4
Re: XPath in Scala
Hi All,
I realise this list is effectively dead but wanted to quickly add
something to this (having realised it was the only group I hadn't
migrated to). I have been working on Scales Xml for a while now
(almost ready for a 0.1 release) and this was one of my driving forces
- how hard can it be?
Turns out that the E1/E2 issue is a tough one - E2's context depends
on the context of E1 and not just its evaluation, but the rest works
fairly smoothly. What I've not got is a satisfactory solution to
reverse axis', other than that its very usable already from the
snapshots:
http://code.google.com/p/scala-scales/wiki/ScalesXml
contains a bunch of examples. I'm working on tweaking the site
generation (sbt plugin) before I clean it up a bit more (exceptions on
invalid ncnames, streamwriter - with customisable attribute ordering,
and probably a TreeMap/Set instead of the current ListSet for an
elements attributes).
Cheers,
Chris
Re the E1/E2 problem I'm not giving up but I think getting a base code
out in peoples hands to play with first makes more sense.
On Feb 8, 2:35 pm, Marcus Downing wrote:
> More than two years ago, I expressed a wish for Scala's native XML to
> support XPath queries. Looking through the mailing lists and elsewhere,
> quite a few other people have asked for something similar. Is there any
> implementation, either out there or under way?
The same question should be addressed to other necessaries in the XML environment: xsl, xslt, validation against a schema, DOM like API, ... .
As far as I know we have a native implementation for JAXB (that's great and necessary!) and our own data model (there is some criticism about the actual implementation).
My feeling is that we should have a DSL for XML processing, which acts as a layer to existing Java libraries.
Jürgen
On 08.02.2011 13:35, Marcus Downing wrote: