Hi Laslo,

The problem comes from the fact that you are setting your own
DocumentHandler. This isn't a bug in Castor, but rather how you have
your Serializer configured.

Since you are creating your own Serializer you'll need to configure it
yourself to omit the XML declaration. Do the following before you call
serializer.asDocumentHandler();

OutputFormat format = Configuration.getOutputFormat();
format.setOmitXMLDeclaration(true);
serializer.setOutputFormat( format );


Marshaller#setMarshalAsDocument will only work when you've passed in a
writer because it will configure the internal serializer. I'll have to
add this to the documentation.

Thanks,

--Keith

"BEDNARIK,LASLO (HP-Germany,ex1)" wrote:
> 
> Hi again,
> 
> before bringing up another issue let me first say that I enjoy using CASTOR.
> 
> Every time I find an issue I keep telling me it would have been much harder
> to code our project with an own XML-JAVA binding framework - we would
> have surely ended up with more bugs and less features than CASTOR :)
> 
> Having said that here is my issue: I can't seem to get my Marshaller
> instance
> to honour the setMarshalAsDocument() setting. I have tried with both 0.9.3.9
> and today's (jan-25) snapshot. I always get the XML declaration at the
> start.
> 
> Somehow related to this I never get a DOCTYPE in my marshalled XML
> files. The API documentation says (Marshaller.setMarshalAsDocument):
> 
> "Sets whether or not to marshal as a document which includes
> the XML declaration, and if necessary the DOCTYPE declaration"
> 
> So when is it "necessary" to have a DOCTYPE ? I tried to explicitly
> set the root element (Marshaller.setRootElement()) which didn't
> change the behaviour. What did I miss ?
> 
> Thanks for your help,
> 
> Laslo
> 
> PS: I attached an archive containing the schema, JAVA test class and
>       ANT script for reproducing the issue.
>       Only adjust path to castor.jar and xerces.jar in "init" target and
>       run "ant asdoc" and see src/asdoc/out1.xml and .../out2.xml .
>  <<asdoc_test.zip>>
> 
>   ------------------------------------------------------------------------
>                      Name: asdoc_test.zip
>    asdoc_test.zip    Type: Zip Compressed Data (application/x-zip-compressed)
>                  Encoding: base64

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to