Skip to content

Commit

Permalink
Refactor to remove XMLUtils.getDocumentBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
jelovirt committed Nov 1, 2024
1 parent b352c0a commit 35979ee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 1 addition & 3 deletions src/main/java/org/dita/index/IndexPreprocessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ RELIANCE, OR CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT LIMITED TO LOSS OF
import static org.dita.dost.util.Constants.*;

import java.util.*;
import javax.xml.parsers.DocumentBuilder;
import org.dita.dost.log.DITAOTLogger;
import org.dita.dost.util.XMLUtils;
import org.dita.index.configuration.IndexConfiguration;
Expand Down Expand Up @@ -101,8 +100,7 @@ public void setLogger(final DITAOTLogger logger) {
* @return read index terms
*/
IndexPreprocessResult process(final Document input) {
final DocumentBuilder documentBuilder = XMLUtils.getDocumentBuilder();
final Document doc = documentBuilder.newDocument();
final Document doc = input.getImplementation().createDocument(null, null, null);
final Node rootElement = input.getDocumentElement();
final List<IndexEntry> indexes = new ArrayList<>();
final Node node = processCurrNode(rootElement, doc, indexes::add).get(0);
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/org/dita/index/IndexPreprocessorTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ RELIANCE, OR CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT LIMITED TO LOSS OF
import java.util.Collection;
import java.util.Locale;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
Expand All @@ -47,7 +49,6 @@ RELIANCE, OR CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT LIMITED TO LOSS OF
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.dita.dost.log.DITAOTAntLogger;
import org.dita.dost.util.XMLUtils;
import org.dita.index.configuration.IndexConfiguration;
import org.dita.index.configuration.ParseException;
import org.w3c.dom.Document;
Expand All @@ -71,12 +72,13 @@ public class IndexPreprocessorTask extends Task {
public void execute() throws BuildException {
checkParameters();

final DocumentBuilder documentBuilder = XMLUtils.getDocumentBuilder();

final Document doc;
try {
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
final DocumentBuilder documentBuilder = factory.newDocumentBuilder();
doc = documentBuilder.parse(input);
} catch (SAXException | IOException e) {
} catch (SAXException | IOException | ParserConfigurationException e) {
throw new BuildException(e);
}

Expand Down

0 comments on commit 35979ee

Please sign in to comment.