Java Utililty Methods XML Transform

List of utility methods to do XML Transform

Description

The list of methods to do XML Transform are organized into topic(s).

Method

TransformerHandlercreateTransformerHandler(int indent)
create Transformer Handler
if (saxTransformerFactory == null) {
    TransformerFactory tf = TransformerFactory.newInstance();
    if (!tf.getFeature(SAXTransformerFactory.FEATURE))
        throw new SAXException("The TransformerFactory is not a SAXTransformerFactory"); 
    saxTransformerFactory = (SAXTransformerFactory) tf;
try {
    saxTransformerFactory.setAttribute("indent-number", Integer.toString(indent)); 
...
StringcreateTXT(Transformer xf, Node doc)
create TXT
OutputStream os = new ByteArrayOutputStream();
StreamResult res = new StreamResult(os);
xf.transform(new DOMSource(doc), res);
os.close();
return os.toString();
StringexceptionToString(TransformerException exception, boolean showSystemId)
exception To String
StringBuffer message = new StringBuffer(20);
if (exception.getLocator() != null) {
    SourceLocator locator = exception.getLocator();
    appendLocation(message, showSystemId ? locator.getSystemId() : null, locator.getLineNumber(),
            locator.getColumnNumber());
message.append(exception.getMessage());
return message.toString();
...
TransformergetDefaultTransformerFactoryThreadLocal()
get Default Transformer Factory Thread Local
return DEFAULT_TRANSFORMER_THREAD_LOCAL.get();
TransformergetNewTransformer()
get New Transformer
return defaultTransformerFactory.get().newTransformer();
TransformergetThreadedIdentityTransformer(boolean omitXmlDeclaration)
Get a thread-safe Transformer without an assigned transform.
return getTransformer(omitXmlDeclaration, null);
TransformergetThreadedIdentityTransformer(final boolean omitXmlDeclaration)
Get a thread-safe Transformer without an assigned transform.
return getThreadedTransformer(omitXmlDeclaration, null, (String) null);
TransformergetThreadedTransformer(final boolean omitXmlDeclaration, final boolean standalone, final Map threadMap, final String xslURL)
get Threaded Transformer
final Thread currentThread = Thread.currentThread();
Transformer transformer = null;
if (threadMap != null) {
    transformer = (Transformer) threadMap.get(currentThread);
if (transformer == null) {
    if (xslURL == null) {
        transformer = tFactory.newTransformer(); 
...
StringgetTransformedText(File doc, File xsl, Object[] params)
Transform an XML file using an XSL file and an array of parameters.
return getTransformedText(new StreamSource(doc), new StreamSource(xsl), params);
TransformergetTransformer()
get Transformer
TransformerFactory tf = TransformerFactory.newInstance();
return tf.newTransformer();