From 52e63c361ff50781d5a4c65f14ad8a6f10a41685 Mon Sep 17 00:00:00 2001 From: Georgy Litvinov Date: Wed, 16 Aug 2023 10:44:39 +0200 Subject: [PATCH] set trasformer factory implementation --- .../dynapi/components/operations/XMLTransformation.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/dynapi/components/operations/XMLTransformation.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/dynapi/components/operations/XMLTransformation.java index e240108b35..4b13637ece 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/dynapi/components/operations/XMLTransformation.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/dynapi/components/operations/XMLTransformation.java @@ -77,8 +77,11 @@ private ByteArrayOutputStream transform(String input, String styles) throws Exce InputStream styleInputStream = IOUtils.toInputStream(styles, StandardCharsets.UTF_8); Source stylesource = new StreamSource(styleInputStream); ByteArrayOutputStream output = new ByteArrayOutputStream(); - TransformerFactory transformerFactory = TransformerFactory.newInstance(); + TransformerFactory transformerFactory = TransformerFactory.newInstance("net.sf.saxon.TransformerFactoryImpl", null); Transformer transformer = transformerFactory.newTransformer(stylesource); + if (transformer == null) { + throw new Exception("Failed to initialize transformer. Check styles."); + } DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(inputStream);