Class StandardXmlFactory
java.lang.Object
org.apache.rat.utils.StandardXmlFactory
Factory to create standard XML objects. The intention of this class is to resolve in a consistent manner the
XXE errors and similar XML IO errors.
-
Method Summary
Modifier and TypeMethodDescriptionstatic TransformerCreate a transformer with no stylesheet.static TransformercreateTransformer(InputStream styleIn) Create a transformer with the specified stylesheet.static DocumentBuilderCreates a DocumentBuilder with reasonable security settings.static StringserializeDocument(Document document) Write an XML document to a file.static voidwriteDocument(Document document, File file) Write an XML document to a file.
-
Method Details
-
createTransformer
Create a transformer with no stylesheet.- Returns:
- the transformer.
- Throws:
TransformerConfigurationException- on error.
-
createTransformer
public static Transformer createTransformer(InputStream styleIn) throws TransformerConfigurationException Create a transformer with the specified stylesheet.- Parameters:
styleIn- the stylesheet to use.- Returns:
- the transformer.
- Throws:
TransformerConfigurationException- on error.
-
documentBuilder
Creates a DocumentBuilder with reasonable security settings.- Returns:
- a DocumentBuilder.
-
writeDocument
public static void writeDocument(Document document, File file) throws IOException, TransformerException Write an XML document to a file.- Parameters:
document- the document to write.file- the file to write to.- Throws:
IOExceptionTransformerException
-
serializeDocument
Write an XML document to a file.- Parameters:
document- the document to write.- Throws:
TransformerException
-