Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Remove "standalone" attribute from from XML declaration

843834Dec 14 2009 — edited Dec 18 2009
Hi everybody,
I am modifying an xml file and when I'm saving it standalone attribute apears in xml declaration.
The original xml has the declaration like this:
<?xml version="1.0" encoding="UTF-8"?>
The new xml declaration is:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
Java code looks like this:
    Transformer transformer = TransformerFactory.newInstance().newTransformer();
    transformer.setOutputProperty(OutputKeys.METHOD,"xml");
    StreamResult output = new StreamResult(new FileWriter(file));
    DOMSource source = new DOMSource(workDocument);
    transformer.transform(source, output);
    output.getWriter().flush();
    output.getWriter().close();
I am using Java 1.6.0.13
Is there any way to remove standalone attribute?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 15 2010
Added on Dec 14 2009
12 comments
11,151 views