Class DocumentHelper

java.lang.Object
org.apache.poi.ooxml.util.DocumentHelper

public final class DocumentHelper extends Object
  • Method Details

    • newDocumentBuilder

      public static DocumentBuilder newDocumentBuilder()
      Creates a new document builder, with sensible defaults
      Throws:
      IllegalStateException - If creating the DocumentBuilder fails, e.g. due to ParserConfigurationException.
    • 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:
      IOException
      SAXException
    • 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:
      IOException
      SAXException
    • 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.
    • addNamespaceDeclaration

      public static void addNamespaceDeclaration(Element element, Namespace namespace)
      Adds a namespace declaration attribute to the given element.