Marshaller and Unmarshaller XML:-
XML Marshaller:A marshaller serializes an object to XML.Here we will
describe the Spring interfaces used for this purpose.
Spring abstracts all marshalling operations behind the
org.springframework.oxm.Marshaller interface, the main methods of this as
shows below.
public interface Marshaller {
/**
* Marshals the object graph with the given root into the provided Result.
*/
void marshal(Object graph, Result result) throws XmlMappingException, IOException;
}
The Marshaller interface has one main method, which marshals the given object to a given javax.xml.transform.Result. Result is a tagging interface that basically represents an XML output abstraction: concrete implementations wrap various XML representations, as described below:
Result implementation |
Wraps XML representation |
DOMResult |
org.w3c.dom.Node |
SAXResult |
org.xml.sax.ContentHandler |
StreamResult |
java.io.File, java.io.OutputStream, or java.io.Writer |