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

javax.xml.transform.TransformergetTransformer()
get Transformer
if (s_transformer != null) {
} else {
    try {
        s_transformer = getTransformerFactory().newTransformer();
        s_transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
        s_transformer.setOutputProperty(javax.xml.transform.OutputKeys.INDENT, "yes");
    } catch (javax.xml.transform.TransformerConfigurationException tce) {
        throw new RuntimeException(tce);
...
TransformergetTransformer()
get Transformer
if (transformer == null) {
    try {
        transformer = TransformerFactory.newInstance().newTransformer();
        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    } catch (Exception e) {
        e.printStackTrace();
        return null;
return transformer;
TransformergetTransformer()
get Transformer
return getTransformerFactory().newTransformer();
TransformergetTransformer()
get Transformer
TransformerFactory tf;
try {
    tf = TransformerFactory.newInstance();
} catch (TransformerFactoryConfigurationError e) {
    System.setProperty("javax.xml.transform.TransformerFactory", TRANSFORMER_FACTORY_JDK5);
    tf = TransformerFactory.newInstance();
if (tf != null) {
...
TransformergetTransformer()
get Transformer
Transformer transformer = null;
try {
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    transformer = transformerFactory.newTransformer();
} catch (Exception exception) {
    exception.printStackTrace();
return transformer;
...
TransformergetTransformer()
get Transformer
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
return transformer;
TransformergetTransformer(boolean omitXmlDeclaration, String xslURL)
Get a thread-safe Transformer.
return getTransformer(omitXmlDeclaration, true, xslURL);
TransformergetTransformer(boolean standalone, boolean indent, int indentNumber, boolean omitXmlDeclaration)
get Transformer
TransformerFactory f = TransformerFactory.newInstance();
f.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
if (indent) {
    f.setAttribute("indent-number", indentNumber);
Transformer t = f.newTransformer();
if (standalone) {
    t.setOutputProperty(OutputKeys.STANDALONE, "yes");
...
TransformergetTransformer(final InputStream xsl)
get Transformer
return TransformerFactory.newInstance().newTransformer(new StreamSource(xsl));
TransformergetTransformer(Source xsltSource)
Gets a new instance from a Transformer object.
return TRANSFORMER_FACTORY.newTransformer(xsltSource);