how can we get like "<?xml version="1.0" encoding="UTF-8" standalone="yes"?>" by using castor

6.7k Views Asked by At

by using normal xml am able to get standalone="yes" attribute with "xml" tag. But when I am trying to get like following by using CASTOR XML am unable. answer will be appreciate. Thanks in advance.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1

There are 1 best solutions below

0
SatishY On

Castor by default generate the XML declaration as follows

<?xml version="1.0" encoding="UTF-8" ?>

In my investigation I didn't get any castor mapping configuration to generate customized XML declaration. So, we can handle it as follows,

writer.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>");

After appending our own XML declaration to writer, we need to suppress Castor not to generate the XML declaration.

marshaller.setSupressXMLDeclaration(true);