Ok, I got it. A little bit code digging and hacking shows
the reason for the described behaviour:
The marshaller get the serializer from Configuration. There
the serializer get the OutputFormat with predefined settings
for method and indenting - and for encoding! But null for
encoding isn't a good idea for further processing as shown
below.
Changing the code in class org.exolab.castor.util.Configuration,
method getOutputFormat() as shown below, and it will work.
---original code---
...
OutputFormat format = new OutputFormat( Method.XML, null, indent );
...
---/original code---
---changed code---
...
OutputFormat format = new OutputFormat();
format.setMethod( Method.XML );
format.setIndenting( indent );
...
---/changed code---
This code will not affect the default setting for encoding (UTF-1).
BTW, should it not be an idea to provide a marshalling method
with the generated classes, that takes two parameters:
writer and encoding ?
Thomas
Thomas Paradies wrote:
> Sorry about the question, but searching for answers in
> the mailing lists is terrible:
>
> How may I control the encoding for marshalling/unmarshalling?
>
> I'm using UTF-8 encoding for my schema, but the marshaling
> to files show me entities as ß or Ä for some special
> german characters.
> I'm using InputStreamReader/OutputStreamWriter with an
> UTF-8 encoding for marshalling/unmarshalling, but the files
> are always beginning with <?xml version="1.0"?> and I always
> got the unwanted entities.
>
> Some ideas?
>
> Thomas
>
> -----------------------------------------------------------
> 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