xmlxsdjaxbxml-binding

Remove 'standalone="yes"' from generated XML


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"?>

Solution

  • This property:

    marshaller.setProperty("com.sun.xml.bind.xmlDeclaration", false);
    

    ...can be used to have no:

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

    However, I wouldn't consider this best practice.