users@jaxb.java.net

AW: Re: Encoding Problem With Marshaller?

From: Nick Pellow <nick.pellow_at_mindmatics.de>
Date: Wed, 27 Oct 2004 19:23:31 +0200

HI Jason,

I have had the same problem as you.

Did you find a more elegant means to do this other than:

unmarshaller.unmarshal(
                    new StreamSource( new StringReader( xmlString )));

?

Cheers,
Nick.

>-----Ursprüngliche Nachricht-----
>Von: Jason Weis [mailto:jweis_at_apelon.com]
>Gesendet: Donnerstag, 21. Oktober 2004 13:52
>An: users_at_jaxb.dev.java.net
>Betreff: RE: Re: Encoding Problem With Marshaller?
>
>
>Thanks. Using the Reader worked. Also, I was using
>com.sun.xml.bind.StringInputStream.
>
>-----Original Message-----
>From: Kohsuke Kawaguchi [mailto:Kohsuke.Kawaguchi_at_Sun.COM]
>Sent: Wednesday, October 20, 2004 4:55 PM
>To: users_at_jaxb.dev.java.net
>Subject: Re: Encoding Problem With Marshaller?
>
>Jason Weis wrote:
>> I am trying to marshall and unmarshall the Ó character which
>appears to have the
>> hex value F3. The following code fragment throws an exception
>(listed below)
>> after the second attempt to Unmarshall. To be clear, the first
>unmarshall works,
>> but after calling marshall and writing to a String,
>unmarshalling that same
>> string fails. Am I doing wrong or is something broken?
>
>The following line looks wrong to me:
>
> Object o = un.unmarshal(new StringInputStream(s));
>
>I'm not sure what "StringInputStream" you are using. If you are using
>com.sun.xml.bind.StringInputStream, then you shouldn't be using an RI
>internal implementation class.
>
>In any case, you are parsing String into InputStream, and therefore you
>are losing the encoding information right there, and unless you do that
>conversion correctly, you'll get an error like this.
>
>If you have a String, char[] or any input that has encoding information,
>wrap that into Reader like this:
>
> new StringReader(s);
>
>This should make it work.
>
>--
>Kohsuke Kawaguchi
>Sun Microsystems kohsuke.kawaguchi_at_sun.com
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
>For additional commands, e-mail: users-help_at_jaxb.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
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net