diff options
author | Andreas Eriksen <andreer@yahooinc.com> | 2022-08-05 22:15:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-05 22:15:14 +0200 |
commit | 866cc9b345768d238f1790b60e052a004e6740bc (patch) | |
tree | 3a44d3b595c20b14cbba6fb1dff383e121e794d9 /vespajlib/src/main/java/com/yahoo/text | |
parent | 1d89c41ce6ecdb56a29317984086740b8ac008d4 (diff) |
use namespace unaware parser for bundle validator MERGEOK (#23585)
* use namespace unaware parser for bundle validator
* update abi spec
Diffstat (limited to 'vespajlib/src/main/java/com/yahoo/text')
-rw-r--r-- | vespajlib/src/main/java/com/yahoo/text/XML.java | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/text/XML.java b/vespajlib/src/main/java/com/yahoo/text/XML.java index 6cc042123dc..6aa42773ac0 100644 --- a/vespajlib/src/main/java/com/yahoo/text/XML.java +++ b/vespajlib/src/main/java/com/yahoo/text/XML.java @@ -452,7 +452,7 @@ public class XML { * @throws RuntimeException if we fail to create one */ public static DocumentBuilder getDocumentBuilder() { - return getDocumentBuilder("com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl", null); + return getDocumentBuilder("com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl", null, true); } /** @@ -464,9 +464,33 @@ public class XML { * @return a DocumentBuilder */ public static DocumentBuilder getDocumentBuilder(String implementation, ClassLoader classLoader) { + return getDocumentBuilder(true); + } + + /** + * Creates a new XML DocumentBuilder + * + * @return a DocumentBuilder + * @throws RuntimeException if we fail to create one + * @param namespaceAware Whether the parser should be aware of xml namespaces + */ + public static DocumentBuilder getDocumentBuilder(boolean namespaceAware) { + return getDocumentBuilder("com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl", null, namespaceAware); + } + + /** + * Creates a new XML DocumentBuilder + * + * @param implementation which jaxp implementation should be used + * @param classLoader which class loader should be used when getting a new DocumentBuilder + * @param namespaceAware Whether the parser should be aware of xml namespaces + * @throws RuntimeException if we fail to create one + * @return a DocumentBuilder + */ + public static DocumentBuilder getDocumentBuilder(String implementation, ClassLoader classLoader, boolean namespaceAware) { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(implementation, classLoader); - factory.setNamespaceAware(true); + factory.setNamespaceAware(namespaceAware); // Disable include directives. If enabled this allows inclusion of any resource, such as file:/// and // http:///, and these are read even if the document eventually fails to parse factory.setXIncludeAware(false); |