Class DOMUtils
java.lang.Object
se.swedenconnect.cert.extensions.utils.DOMUtils
XML DOM Utils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DocumentCreate new empty XML documentstatic byte[]getCanonicalDocText(Document doc, boolean xmlDeclaration) Provides a canonical print of the XML document.static DocumentgetDocument(byte[] xmlData) static DocumentgetNormalizedDocument(byte[] xmlData) static StringgetStyledDocText(Document doc, boolean xmlDeclaration) Generates a pretty XML print of an XML document based on java.xml functions.static DocumentloadXMLContent(File xmlFile) Pare an XML file and returns an XML document
-
Constructor Details
-
DOMUtils
public DOMUtils()
-
-
Method Details
-
getStyledDocText
public static String getStyledDocText(Document doc, boolean xmlDeclaration) throws TransformerException Generates a pretty XML print of an XML document based on java.xml functions.- Parameters:
doc- The doc being processedxmlDeclaration- defines if an XML declaration prefix should be included- Returns:
- Test representation of the XML document
- Throws:
TransformerException- error processing the xml document
-
getCanonicalDocText
public static byte[] getCanonicalDocText(Document doc, boolean xmlDeclaration) throws TransformerException Provides a canonical print of the XML document. The purpose of this print is to try to preserve integrity of an existing signature.- Parameters:
doc- The XML document being processed.xmlDeclaration- true to include XML declaration prefix- Returns:
- XML String
- Throws:
TransformerException- error processing the xml document
-
getNormalizedDocument
public static Document getNormalizedDocument(byte[] xmlData) throws ParserConfigurationException, IOException, SAXException -
getDocument
public static Document getDocument(byte[] xmlData) throws IOException, SAXException, ParserConfigurationException -
loadXMLContent
public static Document loadXMLContent(File xmlFile) throws IOException, ParserConfigurationException, SAXException Pare an XML file and returns an XML document- Parameters:
xmlFile- The XML file being parsed- Returns:
- XML document
- Throws:
IOException- IO data exceptionParserConfigurationException- error setting up XML parserSAXException- xml processing error
-
createNewDocument
Create new empty XML document- Returns:
- new empty XML document
-