Skip to content

Commit

Permalink
Revert "Remove setting the access external for XML parsing factories (#…
Browse files Browse the repository at this point in the history
…199)"

This reverts commit 8ce5167.

Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
  • Loading branch information
flo-dup committed Jan 28, 2021
1 parent 8bbddf0 commit 0572d49
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.powsybl.commons.exceptions.UncheckedTransformerException;
import org.w3c.dom.Document;

import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
Expand All @@ -32,6 +33,8 @@ private DomUtil() {
public static DocumentBuilder getDocumentBuilder() {
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
dbf.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
return dbf.newDocumentBuilder();
} catch (ParserConfigurationException e) {
throw new UncheckedParserConfigurationException(e);
Expand All @@ -43,6 +46,8 @@ public static void transformDocument(Document document, Writer writer) {
DOMSource source = new DOMSource(document);
StreamResult result = new StreamResult(writer);
TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
Transformer transformer = transformerFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
Expand Down

0 comments on commit 0572d49

Please sign in to comment.