users@jaxb.java.net

Re: How to transform Element to String [WAS: Re: How to use anytype: get and set value in pojo]

From: Martin Grotzke <martin.grotzke_at_javakaffee.de>
Date: Fri, 22 Feb 2008 09:33:10 +0100

Hi Alexei,

thanx, it's good to know not to be completely wrong :)

Thanx also for your hint concerning hyperjaxb3, I didn't know this
project.

Thx && cheers,
Martin


On Wed, 2008-02-20 at 09:11 +0100, Aleksei Valikov wrote:
> Hi.
>
> > just reposting the second part of my issue:
> >
> > XJC generates an @XmlAnyElement Element, which is what I want. Now I'm
> > left with the question, what's the best way to read the element to s.th.
> > I could store in the database (e.g. a string), and how to recreate an
> > Element from e.g. a string.
> >
> > Is it good (in terms of performance, simplicity) to do this by using
> > Transformer, DOMSource and StringWrite/StreamResult like this:
> >
> > final DOMSource source = new DOMSource( any );
> > final Transformer transformer =
> > TransformerFactory.newInstance().newTransformer();
> > final StringWriter stringWriter = new StringWriter();
> > final StreamResult result = new StreamResult( stringWriter );
> > transformer.transform( source, result );
> >
> > Or is there an easier way?
>
> This is what I usually do.
>
> Bye.
> /lexi
> ps. Are you aware of https://hyperjaxb3.dev.java.net?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>