@@ -42,7 +42,7 @@ public final class PolicyChecker {
4242
4343 private static final Logger LOGGER = Logger .getLogger (PolicyChecker .class .getCanonicalName ());
4444
45- private static final TransformerFactory factory = TransformerFactory . newInstance ();
45+ private static final TransformerFactory factory = getTransformerFactory ();
4646 public static final String SCHEMA_EXT = "sch" ; //$NON-NLS-1$
4747 public static final String XSL_EXT = "xsl" ; //$NON-NLS-1$
4848 public static final String XSLT_EXT = "xslt" ; //$NON-NLS-1$
@@ -63,15 +63,6 @@ public final class PolicyChecker {
6363 private static final String mergeXsl = resourcePath + "MergeMrrPolicy" + '.' + XSL_EXT ; //$NON-NLS-1$
6464 private static final Templates cachedMergeXsl = SchematronPipeline .createCachedTransform (mergeXsl );
6565
66- static {
67- try {
68- factory .setFeature (XMLConstants .FEATURE_SECURE_PROCESSING , true );
69- factory .setAttribute (XMLConstants .ACCESS_EXTERNAL_STYLESHEET , "file" );
70- } catch (TransformerConfigurationException ignored ) {
71- LOGGER .log (Level .WARNING , "Unable to secure xsl transformer" );
72- }
73- }
74-
7566 private PolicyChecker () {
7667
7768 }
@@ -97,6 +88,7 @@ public static void insertPolicyReport(final File policyReport, final File mrrRep
9788 Transformer transformer = cachedMergeXsl .newTransformer ();
9889 transformer .setParameter ("policyResultPath" , policyReport .getAbsolutePath ()); //$NON-NLS-1$
9990 transformer .transform (new StreamSource (mrrReport ), new StreamResult (mergedReport ));
91+ return ;
10092 } catch (TransformerException excep ) {
10193 throw new VeraPDFException ("Problem merging XML files." , excep ); //$NON-NLS-1$
10294 }
@@ -215,4 +207,15 @@ private static void applySchematronXsl(final InputStream schematronXsl, final In
215207 Transformer transformer = factory .newTransformer (new StreamSource (schematronXsl ));
216208 transformer .transform (new StreamSource (xmlReport ), new StreamResult (policyReport ));
217209 }
210+
211+ private static TransformerFactory getTransformerFactory () {
212+ TransformerFactory fact = TransformerFactory .newInstance ();
213+ try {
214+ fact .setFeature (XMLConstants .FEATURE_SECURE_PROCESSING , true );
215+ fact .setAttribute (XMLConstants .ACCESS_EXTERNAL_STYLESHEET , "file" );
216+ } catch (TransformerConfigurationException e ) {
217+ LOGGER .log (Level .WARNING , "Unable to secure xsl transformer" );
218+ }
219+ return fact ;
220+ }
218221}
0 commit comments