Returns the DocumentPrinter instance attached to the current thread.
Returns a new ThreadLocalDocumentPrinter instance, but omitting the XML declaration.
Returns a new ThreadLocalDocumentPrinter instance, but omitting the XML declaration.
Converts the Document
to a String
, using the DocumentPrinter attached to the current thread.
Converts the Document
to a String
, using the DocumentPrinter attached to the current thread.
Serializes the Document
to an output stream, using the given encoding, and using the DocumentPrinter attached to the current thread.
Serializes the Document
to an output stream, using the given encoding, and using the DocumentPrinter attached to the current thread.
Converts the Elem
to a String
, omitting the XML declaration.
Converts the Elem
to a String
, omitting the XML declaration. May use a lot of memory for large XML documents.
To have more control over the character encoding of the output, when converting the String to bytes
(and of the encoding mentioned in the XML declaration, if any), consider using one of the other overloaded
print
methods taking an Elem
.
Serializes the Elem
to an output stream, omitting the XML declaration.
Serializes the Elem
to an output stream, omitting the XML declaration.
This method should close the output stream afterwards.
Converts the Elem
to a byte array, omitting the XML declaration
Converts the Elem
to a byte array, omitting the XML declaration
Converts the Document
to a byte array, using the given encoding.
Converts the Document
to a byte array, using the given encoding. May use a lot of memory for large XML documents.
Thread-local DocumentPrinter. This class exists because typical JAXP factory objects (DocumentBuilderFactory etc.) are not thread-safe, but still expensive to create. Using this DocumentPrinter facade backed by a thread local DocumentPrinter, we can create a ThreadLocalDocumentPrinter once, and re-use it all the time without having to worry about thread-safety issues.
Note that each ThreadLocalDocumentPrinter instance (!) has its own thread-local document printer. Typically it makes no sense to have more than one ThreadLocalDocumentPrinter instance in one application. In a Spring application, for example, a single instance of a ThreadLocalDocumentPrinter can be configured.