JAXB marshals XML differently to OutputStream vs. StringWriter
问题 I apologize if this has been answered, but the search terms I have been using (i.e. JAXB @XmlAttribute condensed or JAXB XML marshal to String different results ) aren't coming up with anything. I am using JAXB to un/marshal objects annotated with @XmlElement and @XmlAttribute annotations. I have a formatter class which provides two methods -- one wraps the marshal method and accepts the object to marshal and an OutputStream , the other just accepts the object and returns the XML output as a