Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala: jaxb or similar?

Tags:

xml

jaxb

scala

As a java programmer I'm quite comfortable with using JAXB and similar, for example to construct object from a XML spec.

I'm sure I can make JAXB work nice in scala, but I wonder if that is the scala way of doing it, or if there is some better/smarter way, especially since XML is almost part of the language / it's internal libraries.

So, given that I want to create a set of object form a XML spec, what's the recommended way to do this in scala?

like image 801
Bjorn J Avatar asked Sep 06 '10 19:09

Bjorn J


2 Answers

For pure Scala, there is scalaxb. It generates case classes and parser based on Scala parser combinators. It's still quite young, but if you steer clear of the advanced features of XML Schema it is quite usable.

like image 96
retronym Avatar answered Oct 14 '22 06:10

retronym


Ditto on Scalaxb.

Has an issue with '-' in class and field name, turns into "u45" !!

You can fix with this code, to fix in place with this gist:

PostProcessScalaxb

like image 25
Dino Fancellu Avatar answered Oct 14 '22 05:10

Dino Fancellu