Package org.apache.poi.ooxml.util
Class DocumentHelper
- java.lang.Object
-
- org.apache.poi.ooxml.util.DocumentHelper
-
public final class DocumentHelper extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddNamespaceDeclaration(Element element, String namespacePrefix, String namespaceURI)Adds a namespace declaration attribute to the given element.static voidaddNamespaceDeclaration(Element element, Namespace namespace)Adds a namespace declaration attribute to the given element.static DocumentcreateDocument()Creates a new DOM Documentstatic DocumentBuildernewDocumentBuilder()Creates a new document builder, with sensible defaultsstatic DocumentreadDocument(InputStream inp)Parses the given stream via the default (sensible) DocumentBuilderstatic DocumentreadDocument(InputSource inp)Parses the given stream via the default (sensible) DocumentBuilder
-
-
-
Method Detail
-
newDocumentBuilder
public static DocumentBuilder newDocumentBuilder()
Creates a new document builder, with sensible defaults- Throws:
IllegalStateException- If creating the DocumentBuilder fails, e.g. due toParserConfigurationException.
-
readDocument
public static Document readDocument(InputStream inp) throws IOException, SAXException
Parses the given stream via the default (sensible) DocumentBuilder- Parameters:
inp- Stream to read the XML data from- Returns:
- the parsed Document
- Throws:
IOExceptionSAXException
-
readDocument
public static Document readDocument(InputSource inp) throws IOException, SAXException
Parses the given stream via the default (sensible) DocumentBuilder- Parameters:
inp- sax source to read the XML data from- Returns:
- the parsed Document
- Throws:
IOExceptionSAXException
-
createDocument
public static Document createDocument()
Creates a new DOM Document
-
addNamespaceDeclaration
public static void addNamespaceDeclaration(Element element, String namespacePrefix, String namespaceURI)
Adds a namespace declaration attribute to the given element.
-
-