Package: groovy.xml

## [Java] Class DOMBuilder

- groovy.xml.DOMBuilder

- A helper class for creating a W3C DOM tree

  Authors:
    James Strachan

- - ### Constructor Summary

    Constructors
    Constructor and description
    `DOMBuilder (Document document)`
    `DOMBuilder (DocumentBuilder documentBuilder)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `protected void` | `appendNamespaceAttributes(Element element, Map<Object, Object> attributes)`
    `` | `protected Document` | `createDocument()`
    `` | `protected Object` | `createNode(Object name)`
    `` | `protected Object` | `createNode(Object name, Object value)`
    `` | `protected Object` | `createNode(Object name, Map attributes, Object value)`
    `` | `protected Object` | `createNode(Object name, Map attributes)`
    `` | `static DOMBuilder` | `newInstance()`
    `` | `static DOMBuilder` | `newInstance(boolean validating, boolean namespaceAware)`
    `` | `static Document` | `parse(Reader reader)` Creates a DocumentBuilder and uses it to parse the XML text read from the given reader.
    `` | `static Document` | `parse(Reader reader, boolean validating, boolean namespaceAware)` Creates a DocumentBuilder and uses it to parse the XML text read from the given reader, allowing parser validation and namespace awareness to be controlled.
    `` | `static Document` | `parse(Reader reader, boolean validating, boolean namespaceAware, boolean allowDocTypeDeclaration)` Creates a DocumentBuilder and uses it to parse the XML text read from the given reader, allowing parser validation, namespace awareness and permission of DOCTYPE declarations to be controlled.
    `` | `Document` | `parseText(String text)` A helper method to parse the given text as XML.
    `` | `protected void` | `setParent(Object parent, Object child)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class BuilderSupport` | `createNode, createNode, createNode, createNode, doInvokeMethod, getCurrent, getName, invokeMethod, invokeMethod, nodeCompleted, postNodeCompletion, setClosureDelegate, setCurrent, setParent`
    `class GroovyObjectSupport` | `getMetaClass, getProperty, invokeMethod, setMetaClass, setProperty`
    `class Object` | `equals, toString, hashCode, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### public DOMBuilder(Document document)

    - #### public DOMBuilder(DocumentBuilder documentBuilder)

  - ### Method Detail

    - #### protected void appendNamespaceAttributes(Element element, Map<Object, Object> attributes)

    - #### protected Document createDocument()

    - #### protected Object createNode(Object name)

    - #### protected Object createNode(Object name, Object value)

    - #### protected Object createNode(Object name, Map attributes, Object value)

    - #### protected Object createNode(Object name, Map attributes)

    - #### public static DOMBuilder newInstance()

    - #### public static DOMBuilder newInstance(boolean validating, boolean namespaceAware)

    - #### public static Document parse(Reader reader)

      Creates a DocumentBuilder and uses it to parse the XML text read from the given reader. A non-validating, namespace aware parser which does not allow DOCTYPE declarations is used.

      throws:
        SAXException Any SAX exception, possibly wrapping another exception.
      throws:
        IOException An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
      throws:
        ParserConfigurationException if a DocumentBuilder cannot be created which satisfies the configuration requested.
      Parameters:
        `reader` - the reader to read the XML text from
      Returns:
        the root node of the parsed tree of Nodes
      See Also:
        parse(Reader, boolean, boolean)

    - #### public static Document parse(Reader reader, boolean validating, boolean namespaceAware)

      Creates a DocumentBuilder and uses it to parse the XML text read from the given reader, allowing parser validation and namespace awareness to be controlled. Documents are not allowed to contain DOCYTYPE declarations.

      throws:
        SAXException Any SAX exception, possibly wrapping another exception.
      throws:
        IOException An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
      throws:
        ParserConfigurationException if a DocumentBuilder cannot be created which satisfies the configuration requested.
      Parameters:
        `reader` - the reader to read the XML text from
        `validating` - whether to validate the XML
        `namespaceAware` - whether the parser should be namespace aware
      Returns:
        the root node of the parsed tree of Nodes

    - #### public static Document parse(Reader reader, boolean validating, boolean namespaceAware, boolean allowDocTypeDeclaration)

      Creates a DocumentBuilder and uses it to parse the XML text read from the given reader, allowing parser validation, namespace awareness and permission of DOCTYPE declarations to be controlled.

      throws:
        SAXException Any SAX exception, possibly wrapping another exception.
      throws:
        IOException An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
      throws:
        ParserConfigurationException if a DocumentBuilder cannot be created which satisfies the configuration requested.
      Parameters:
        `reader` - the reader to read the XML text from
        `validating` - whether to validate the XML
        `namespaceAware` - whether the parser should be namespace aware
        `allowDocTypeDeclaration` - whether the parser should allow DOCTYPE declarations
      Returns:
        the root node of the parsed tree of Nodes

    - #### public Document parseText(String text)

      A helper method to parse the given text as XML.

      throws:
        SAXException Any SAX exception, possibly wrapping another exception.
      throws:
        IOException An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
      throws:
        ParserConfigurationException if a DocumentBuilder cannot be created which satisfies the configuration requested.
      Parameters:
        `text` - the XML text to parse
      Returns:
        the root node of the parsed tree of Nodes
      See Also:
        parse(Reader)

    - #### protected void setParent(Object parent, Object child)