[Home] [By Thread] [By Date] [Recent Entries]

  • From: Hans-Juergen Rennau <hrennau@y...>
  • To: Michael Kay <mike@s...>, "xml-dev@l..." <xml-dev@l...>
  • Date: Thu, 22 Jun 2017 13:54:26 +0000 (UTC)

That does look promising and stirs curiosity. But while you are at it, could you not - at least, in principle - do it exactly the other way around - rather than define representations of flatMap() as /, etc., define a translation of / into flatMap(), etc - in short, a compilation of XPath into your low-level, streaming API expressions? Per mainstream, Java people are using a JAXB compilation step in their build processes anyway, adding an XPath compilation step would not hurt at all, and safety is at its maximum, as is expressiveness.  


Michael Kay <mike@s...> schrieb am 15:33 Donnerstag, 22.Juni 2017:



(2) A great challenge - and perhaps a hopeless one - would be to create an expressiveness which could at least be a far cry of what XPath offers. It is strange to say
     N.walk(Axis.child("city")).flatMap(Axis.attribute("name").map(Node::stringValue)
when what you really want to say is
     city/@name


Excellent point. However, dropping into another language does have all sorts of disadvantages: apart from the learning issues, there's the lack of compile-time syntax checking and type checking, the cost of dynamic compilation/interpretation, etc.

One thing to look at, perhaps, is how it translates into Scala, where you can define your own operators:

A.flatMap(B)   -->   A/B

A.attribute(B)  -->   A @ B

etc; and then we start to have something very XPath-like, but with a syntax that's compiled and validated by the host language.

Michael Kay
Saxonica 





[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member