Class XmlFactories
java.lang.Object
org.projecthusky.common.utils.xml.XmlFactories
@DefaultQualifier(value=org.checkerframework.checker.nullness.qual.NonNull.class,
locations={PARAMETER,RETURN})
public class XmlFactories
extends Object
Factories for XML-related classes.
- Author:
- Quentin Ligier
-
Method Summary
Modifier and TypeMethodDescriptionstatic DocumentBuilder
Initializes and configures aDocumentBuilder
that is not vulnerable to XXE injections (XInclude, Billions Laugh Attack, ...).static Schema
newSafeSchema
(URL schema) Initializes and configures aSchema
.static XPath
Initializes and configures aXPath
.static Transformer
Initializes and configures aTransformer
.static Transformer
newTransformer
(Source source) Initializes and configures aTransformer
from aSource
.
-
Method Details
-
newSafeDocumentBuilder
Initializes and configures aDocumentBuilder
that is not vulnerable to XXE injections (XInclude, Billions Laugh Attack, ...).- Returns:
- a configured
DocumentBuilder
. - Throws:
ParserConfigurationException
- if the parser is not Xerces2 compatible.- See Also:
-
newSafeSchema
Initializes and configures aSchema
.- Parameters:
schema
- URL that represents a schema.- Returns:
- a configured
Schema
. - Throws:
SAXException
- if a SAX error occurs during parsing.
-
newSafeXpath
Initializes and configures aXPath
.- Returns:
- a configured
XPath
. - Throws:
XPathFactoryConfigurationException
- if the configuration fails.
-
newTransformer
Initializes and configures aTransformer
.- Returns:
- a configured
Transformer
. - Throws:
TransformerConfigurationException
- if it is not possible to create aTransformer
instance.
-
newTransformer
Initializes and configures aTransformer
from aSource
. You can useSources
to convert different objects toSource
s.- Parameters:
source
- The source.- Returns:
- a configured
Transformer
. - Throws:
TransformerConfigurationException
- if it is not possible to create aTransformer
instance.
-