Hi, Serg.
Thank you for your solution. This one worked.
Hiran
----- Original Message -----
From: "Serg Maslyukov" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, March 31, 2003 6:40 AM
Subject: Re: [castor-dev] Encoding Problem
> Hi
>
> Try this:
>
> public static byte[] getXml(Object obj, String
> rootElement, String namespace[][], String encoding)
> throws Exception
> {
> ByteArrayOutputStream fos = null;
> try
> {
> fos = new ByteArrayOutputStream(1000);
> Marshaller marsh = new Marshaller( new
> OutputStreamWriter(fos, encoding) );
>
> if (rootElement!=null &&
> rootElement.trim().length()>0)
> marsh.setRootElement( rootElement );
>
> marsh.setMarshalAsDocument(true);
> marsh.setEncoding(encoding);
> if (namespace!=null)
> {
> for (int i=0; i<namespace.length; i++)
> {
>
> marsh.setNamespaceMapping(namespace[i][0],
> namespace[i][1]);
> }
> }
> marsh.marshal(obj);
> marsh = null;
>
> fos.flush();
> fos.close();
>
> return fos.toByteArray();
> }
> catch (Exception e)
> {
> cat.error("Error marshaling object", e);
> throw e;
> }
> finally
> {
> fos = null;
> // System.gc();
> }
> }
>
>
> Serge
>
> --- "Chaudhuri, Hiran"
> <[EMAIL PROTECTED]> wrote:
> > 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
> >
> >
> > > -----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
> >
>
>
> =====
> WebMill - Free XML/XSLT java-based portlet engine.
> http://webmill.askmore.info
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
> http://platinum.yahoo.com
>
> -----------------------------------------------------------
> 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