Skip to content

Commit

Permalink
if the Transformer factory fails to load a Transformer we fall back t…
Browse files Browse the repository at this point in the history
…o the default transformer factory and give that a try
  • Loading branch information
michaeloffner committed Jun 28, 2023
1 parent 03b6c56 commit b509ced
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions build.number
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Fri Nov 11 14:27:36 CET 2022
build.number=20
#Wed Jun 28 15:35:36 CEST 2023
build.number=21
13 changes: 12 additions & 1 deletion source/java/src/org/lucee/extension/pdf/util/XMLUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import java.util.ArrayList;

import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerFactoryConfigurationError;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.sax.SAXSource;

Expand Down Expand Up @@ -75,7 +77,7 @@ public static final Document parseHTML(InputSource xml) throws SAXException, IOE
reader.setFeature(Parser.namespacesFeature, true);
reader.setFeature(Parser.namespacePrefixesFeature, true);
try {
Transformer transformer = getTransformerFactory().newTransformer();
Transformer transformer = getTransformer();

DOMResult result = new DOMResult();
transformer.transform(new SAXSource(reader, xml), result);
Expand All @@ -86,6 +88,15 @@ public static final Document parseHTML(InputSource xml) throws SAXException, IOE
}
}

public static Transformer getTransformer() throws TransformerConfigurationException, TransformerFactoryConfigurationError {
try {
return getTransformerFactory().newTransformer();
}
catch (Exception e) {
return TransformerFactory.newInstance().newTransformer();
}
}

public static TransformerFactory getTransformerFactory() {
if (transformerFactory == null) {
try {
Expand Down

0 comments on commit b509ced

Please sign in to comment.