Do you know of a JAXB setting to prevent standalone="yes" from being generated in the resulting XML?
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
Do you know of a JAXB setting to prevent standalone="yes" from being generated in the resulting XML?
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
in JAXB that is part of JDK1.6
You can use: marshaller.setProperty("jaxb.fragment", Boolean.TRUE);
It works for me on Java 8
can be used to have no
However i wouldnt consider this best practice.
just if someone else is still struggeling with this problem, you may consider using
to remove all of the XML declaration and just write your own
String
at the beginning of your output stream / methodI don't have a high enough "reputation" to have the "privilege" to comment. ;-)
@Debasis, note that the property you've specified:
should be:
If I use the "internal" property as you did, I get a javax.xml.bind.PropertyException
You can either use
or
to disable the default XML declaration, and then add your custom XML declaration,
by
to the generated xml, thus avoiding the standalone="yes" property.