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 DocumentBuilderInitializes and configures aDocumentBuilderthat is not vulnerable to XXE injections (XInclude, Billions Laugh Attack, ...).static SchemanewSafeSchema(URL schema) Initializes and configures aSchema.static XPathInitializes and configures aXPath.static TransformerInitializes and configures aTransformer.static TransformernewTransformer(Source source) Initializes and configures aTransformerfrom aSource.
-
Method Details
-
newSafeDocumentBuilder
Initializes and configures aDocumentBuilderthat 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 aTransformerinstance.
-
newTransformer
Initializes and configures aTransformerfrom aSource. You can useSourcesto convert different objects toSources.- Parameters:
source- The source.- Returns:
- a configured
Transformer. - Throws:
TransformerConfigurationException- if it is not possible to create aTransformerinstance.
-