How to use XML Bindig (f.e. XStream)

20 views
Skip to first unread message

Christopher Schmidt

unread,
Jan 10, 2016, 5:52:40 AM1/10/16
to scales-xml
Hi,

I've got code like this:

for { 
  enterprise <- itr
  enterpriseName <- enterprise \* EName \* Legal
} {
  println("enterprise "+enterpriseName +" has units:")

And I want to bind f.e. enterpriseName to JAXB generated classes or binding it with XStream.

Any hint how to do it?
Or even how to serialize enterpriseName to a XML String?

best Christopher

Chris Twiner

unread,
Jan 10, 2016, 5:54:34 AM1/10/16
to scale...@googlegroups.com
Hi Christopher,

To serialize most parts of Scales you can follow this guide
http://scala-scales.googlecode.com/svn/sites/scales/scales-xml_2.10/0.5.0/SerializingIntro.html
. However in this case I'd probably convert to a trax Source
http://scala-scales.googlecode.com/svn/sites/scales/scales-xml_2.10/0.5.0/XSLT.html
gives an example.

JAXB should be able to take a Source, according to the docs it can as
well as directly consume a converted StAXReader (which Scales also
provides). This means there shouldn't need to be an extra level of
serialization, it will run in the smallest memory possible.

If there is some clunkyness in the usage have a look at
http://scala-scales.googlecode.com/svn/sites/scales/scales-xml_2.10/0.5.0/api.sxr/scales/xml/trax/TraxSupport.scala.html
TraxConversionImplicits for ideas on how to customise the conversion.

Let us know how you get on with it.

Cheers,
Chris
> --
> You received this message because you are subscribed to the Google Groups
> "scales-xml" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to scales-xml+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Christopher Schmidt

unread,
Jan 24, 2016, 10:44:27 AM1/24/16
to scales-xml
Hi Chris, thank for your answer.

JAXB is able to take a Source:

public <T> JAXBElement<T> unmarshal( javax.xml.transform.Source source, Class<T> declaredType )

Maybe a stupid question. How can I get a Source from my enterpriseName? (see code below)

Christopher
Reply all
Reply to author
Forward
0 new messages