> Hi, all.
>
> This time I tried myself what I suggested to Marcel - but it does not
> work.
> Whatever I set the encoding to, the output is UTF-8. I also included the
> line that made no sense in my eyes - with no effect.
> Marcel, did my solution help you?
>
> If not, we have a problem with the marshalling framework. I tried to
> understand Marshaller.java but could not find the lines where Xerces
> Serializers are called with the correct/wrong encoding.
>
> Can anyone help me on that?
>
> Hiran
>
Hi,
In our case we marshal the object to an Document (DOM object).
With this you can use an Transformer to parse your Document to
a form you want. For example a String:
<pseudo code>
StringWriter sw = new StringWriter();
TransformerFactory tfactory = TransformerFactory.newInstance();
Transformer serializer = tfactory.newTransformer();
Properties oprops = new Properties();
oprops.put("method", "xml");
oprops.put("indent", "no");
oprops.put("encoding", "UTF-8");
serializer.setOutputProperties(oprops);
serializer.transform(new DOMSource(node), new StreamResult(sw));
return sw.toString();
</pseudo code>
My experience is, that any encoding i've used so far is correct. We tried
ISO-8859-1 and UTF-8.
There are probably more ways, but this one works ;-)
Good luck
Robin Hoogeboom
>
> > -----Original Message-----
> > From: Chaudhuri, Hiran [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, March 26, 2003 2:15 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: [castor-dev] Encoding Problem
> >
> >
> > Hi, Marcel.
> >
> > That's what I had suspected some time ago. What about this approach:
> >
> > FileOutputStream os=new FileOutputStream(new
> > File("D:\\Temp\\xmlModel.xml"));
> > Writer fw = new OutputStreamWriter(os,
> > "iso-8859-1");
> > fw.write("<?xml version=\"1.0\"
> > encoding=\"iso-8859-1\"?>\n");
> > Marshaller ms=new Marshaller(fw);
> > //ms.setEncoding("ISO-8859-1"); in my eyes this
> > lines has no effect
> > ms.marshal(model,fw);
> > fw.close();
> > os.close();
> >
> > Hiran
> >
> >
> > > -----Original Message-----
> > > From: Marcel Flueckiger [mailto:[EMAIL PROTECTED]
> > > Sent: Wednesday, March 26, 2003 1:37 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: [castor-dev] Encoding Problem
> > >
> > >
> > > I have problems with the encoding Tag in my generated XML
> > > field. I need do declare "ISO-8859-1" instead of utf-8.
> > > i tryed to change the encoding the following way , but it
> > > doesnt work...
> > > FileWriter fw=new FileWriter(new
> > > File("D:\\Temp\\xmlModel.xml"));
> > > Marshaller ms=new Marshaller(fw);
> > > ms.setEncoding("ISO-8859-1");
> > > ms.marshal(model,fw);
> > > fw.close();
> > > But in the generated XML File ist the Encoding still set with UTF-8
> > > Can you help me pleas ...
> > > Thanks Marcel Flueckiger
> > >
> > > -----------------------------------------------------------
> > > If you wish to unsubscribe from this mailing, send mail to
> > > [EMAIL PROTECTED] with a subject of:
> > > unsubscribe castor-dev
> > >
> >
> > -----------------------------------------------------------
> > If you wish to unsubscribe from this mailing, send mail to
> > [EMAIL PROTECTED] with a subject of:
> > unsubscribe castor-dev
> >
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
>
--
_____________________________________________________________________
Zon Breedband Family, 2 keer zo snel als alle andere ADSL aanbieders.
Voor maar 34 euro per maand. Bestel nu op www.zonnet.nl/breedband
Tijdelijk gratis modem en geen aansluitkosten!
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev