Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 17 20:15
    scala-steward closed #142
  • Sep 17 20:15
    scala-steward commented #142
  • Sep 17 20:15
    scala-steward opened #145
  • Jul 14 00:00
    scala-steward closed #143
  • Jul 13 23:59
    scala-steward commented #143
  • Jul 13 23:59
    scala-steward opened #144
  • Jul 11 23:31
    scala-steward opened #143
  • Jul 11 23:31
    scala-steward opened #142
  • Feb 16 12:07

    nrinaudo on update-sbt-1.6.2

    (compare)

  • Feb 16 12:05

    nrinaudo on master

    Update sbt to 1.6.2 Merge pull request #141 from nr… (compare)

  • Feb 16 12:05
    nrinaudo closed #141
  • Feb 16 11:43
    nrinaudo opened #141
  • Feb 16 11:43

    nrinaudo on update-sbt-1.6.2

    Update sbt to 1.6.2 (compare)

  • Feb 16 11:10

    nrinaudo on update-kantan.sbt-2.8.2

    (compare)

  • Feb 16 11:10

    nrinaudo on master

    Update to kantan.sbt 2.8.2 Merge pull request #140 from nr… (compare)

  • Feb 16 11:10
    nrinaudo closed #140
  • Feb 16 10:59
    nrinaudo opened #140
  • Feb 16 10:59

    nrinaudo on update-kantan.sbt-2.8.2

    Update to kantan.sbt 2.8.2 (compare)

  • Jan 13 17:59
    scala-steward closed #135
  • Jan 13 17:59
    scala-steward commented #135
Rob Norris
@tpolecat
We do a bunch of XML crap so I'll certainly be taking a look.
Nicolas Rinaudo
@nrinaudo
@tpolecat thanks!
it's the very first release, so it's still a bit rough with a few questionable design choices that I need to iron out, but I'm quite happy with the direction it's headed
Nicolas Rinaudo
@nrinaudo
@/all kantanx.path v0.1.1 is now available on maven central, with some serious improvements.
In particular, it's now possible to write this:
val input: File = ???

// First match
input.evalXPath[URI]("//a/@href")

// All matches
input.evalXPath[List[URI]]("//a/@href")
Nicolas Rinaudo
@nrinaudo
@/all version 0.1.2 now available on maven central. Mostly a bug fix release, thanks to feedback from @metasim
Nicolas Rinaudo
@nrinaudo
@/all publishing 0.1.8-SNAPSHOT as I type this. Most important improvements are:
  • Scala 2.12 support
  • Java 8 date / time support
  • update to whatever is the latest available version of each dependency
this is probably everything that'll go in 0.1.8 (except for documentation) so feedback would be appreciated
Nicolas Rinaudo
@nrinaudo
@/all official artifacts for 0.1.8 are now available on maven central.
Brandon Elam Barker
@bbarker
@nrinaudo I'm looking at Scala(-friendly) tools for transforming XSDs. For starters, I just want to be able to remove a list of xpaths from a document (in this case, those XPaths would just happen to be XPaths in an XSD). Is there an API to do this in Kantan? would it be reasonable to add something like "<users><user id='1'/><user id='2'/></users>".removeXPath(xp"//user/@id")? Related, I guess having an API for writing to an XML document would be good: val newDoc = "<users><user id='1'/><user id='2'/></users>".setXPath[Int](xp"//user/@id", 2), perhaps
Maybe that's out of scope for Kantan, but just wanted to check here first
Nicolas Rinaudo
@nrinaudo
I'm afraid it kind of is, kantan.xpath is really just about extracting data, not modifying it
Brandon Elam Barker
@bbarker
ok, thanks, I'll keep looking! Still will be nice to use to extract with useful types
Brandon Elam Barker
@bbarker
I wonder why scala.xml didn't use XPath natively ... seems a shame. I verified XPath is 4 years older than Scala ;)
I'll plan to implement a separate, small library that is Kantan-friendly
Nicolas Rinaudo
@nrinaudo
that sounds great, let me know if I can help!
I suppose that, if you're familiar with Java DOM, you could get some of your use cases to work. Do you know, for example, how to remove a set of Nodes from an existing Document?
because if so, you can absolutely execute an xpath query on a Document and get the result(s) as Nodes. If you know how to do the rest, you're set.
by the same token, if you know how to modify the content of a Node, you could get an xpath query running that'd return your target Node and update that
Nicolas Rinaudo
@nrinaudo
I'll be blunt though: I've no intention of wrapping Node, Document and co. in proper Scala types. If you want to implement your use cases within the scope of kantan.xpath, you'll have to deal with "low level" Java types :)
Brandon Elam Barker
@bbarker
@nrinaudo thanks - while I haven't done that before, I believe you've basically confirmed by plan based on what I have read earlier today
Nicolas Rinaudo
@nrinaudo
I'm not 100% sure it's possible - I haven't done Java in years, and still wake up in cold sweat from nightmares about java.xml.*
Brandon Elam Barker
@bbarker
oh thanks, I found another SO link with some suggestions along those lines, I think - https://stackoverflow.com/questions/6124239/how-to-update-xml-using-xpath-and-java - but haven't had a chance to go through it in detail yet
Nicolas Rinaudo
@nrinaudo
So looks like it should be possible, maybe even not too hard, although not necessarily straightforward. Let me know if you get stuck!
Brandon Elam Barker
@bbarker
ok, many thanks! I do not know if I'll be using Kantan at this stage as we're only going for removal of nodes right now, but late on we may plan to get more sophisticated and do updates as well, at which point I think Kantan XPath could be quite helpful
Nicolas Rinaudo
@nrinaudo
If you’re just doing removal, kantan.xpath is probably not terribly useful :)
Brandon Elam Barker
@bbarker
well, I have more XML projects that I would like to admit so there is a fair chance I will use it soon ... ( though I'm in the process of removing JAXB/XSD/XML from one Java project I converted to Scala ... nightmares indeed)
Nicolas Rinaudo
@nrinaudo
fair warning though: if you're trying to get rid of all the Java stuff in order to add support, among other things, to scala.js: kantan.xpath cannot support non-JVM backends, since it's basically a thin wrapper over java.xml.xpath
Howy Perrin
@howyp

Have just found this, looks great so far. Am a bit stuck with doing fall-back resolutions on case classes, I want to be able to do an orElse, something like:

case class Example(a: String, b: String)

NodeDecoder.decode(
  xp”//a”,
  xp”//b”.orElse(xp”//c”)
)(Example.apply)

Is there a neat way to do something like that?

Nicolas Rinaudo
@nrinaudo
isn't that something you can do directly in xpath? //b|c ?
(haven't tried it, it's something I vaguely seem to remember from when I did a lot more xpath than nowadays)
Howy Perrin
@howyp
thanks - I’ll give it a go :-)
From what I can see | is a union operator in XPath - selects these nodes OR those nodes
do you know what version of XPath is supported by kantan.xpath?
Nicolas Rinaudo
@nrinaudo
that's what I thought you meant to do, so I must have misunderstood your problem
not entirely sure, whatever is supported by the JVM
Howy Perrin
@howyp
sorry I’m not explaining myself well. It’s like UNION in SQL - returns all results from the first expression, followed by all from the second expression
Nicolas Rinaudo
@nrinaudo
but basically, if there's no way to do this at the XPath level, you're out of luck - this isn't a use case supported by kantan.xpath
Howy Perrin
@howyp
So after a bit of playing around I can do roughly what I’m after with using expressions like this rather than just the XPath:
Query(xp"(//a")(Compiler.xpath1(NodeDecoder[String].recover { case _ => "" }))
I guess I could use .orElse(…) and another query if I wanted
I couldn’t work out why the Compiler.xpath1 call was needed - in other places it looks as if it acts as an implicit conversion
Nicolas Rinaudo
@nrinaudo
you're forcing me to look at code I've not read in.. years, I think :)
Howy Perrin
@howyp
haha! You’re welcome ;-)
Philippe Derome
@phderome
hello, saw some SO entry yesterday about kantan.xpath.
Nicolas Rinaudo
@nrinaudo
Probably authored by me, to be honest. It’s not exactly a popular library
Xml isn’t a thing that happens much in Scala world
Philippe Derome
@phderome
Yes indeed, this might be relevant to me someday as we use some XML at work