You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For Spring Batch's Xml IO sources will be helpful to have method setXmlDecl(boolean) in org.springframework.oxm.Marshaller interface, which will configure marshaller to turn on/off writing StartDocument event and EndDocument event for each call of marshall() method.
The reason I cannot fix the Marshaller like you suggested in http://opensource.atlassian.com/projects/spring/browse/SWS-181 is this: the Marshaller is very generic: it can marshal to DOM documents, SAX ContentHandlers, file streams, and Stax XMLEventReader/XMLEventWriters. Filtering out the Start/EndDocument events would only work for Stax, and perhaps SAX. Adding a property to this effect would very confusing, since it does not work in other cases (marshalling to DOM). This would break the principle of least astonishment.
But there is a way you can filter out these events, by creating a delegating XMLStreamWriter, which ignores start and end document events, but passes through everything else:
import javax.xml.stream.*;
public class NoStartEndDocumentStreamWriter implements XMLStreamWriter {
private XMLStreamWriter delegate;
public NoStartEndDocumentStreamWriter(XMLStreamWriter delegate) {
this.delegate = delegate;
}
Peter Zozom opened SWS-181 and commented
For Spring Batch's Xml IO sources will be helpful to have method setXmlDecl(boolean) in org.springframework.oxm.Marshaller interface, which will configure marshaller to turn on/off writing StartDocument event and EndDocument event for each call of marshall() method.
See new XML I/O sources attached as SVN patch in issue:
http://opensource.atlassian.com/projects/spring/browse/BATCH-116
Issue Links:
The text was updated successfully, but these errors were encountered: