Package: groovy.xml

## [Java] Class SAXBuilder

- groovy.xml.SAXBuilder

-     public class SAXBuilder
      extends BuilderSupport

  A builder for generating W3C SAX events. Use similar to MarkupBuilder.

- - ### Constructor Summary

    Constructors
    Constructor and description
    `SAXBuilder(ContentHandler handler)` Creates a builder that forwards markup events to the supplied SAX content handler.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `protected Object` | `createNode(Object name)` Builder lifecycle callback that starts an element with no attributes or body text.
    `` | `protected Object` | `createNode(Object name, Object value)` Builder lifecycle callback that starts an element and immediately emits text content.
    `` | `protected Object` | `createNode(Object name, Map attributeMap, Object text)` Builder lifecycle callback that starts an element, emits attributes and optionally emits text content.
    `` | `protected Object` | `createNode(Object name, Map attributes)` Builder lifecycle callback that starts an element and emits attributes without body text.
    `` | `protected void` | `doStartElement(Object name, Attributes attributes)` Emits a SAX `startElement` event for the supplied node name.
    `` | `protected void` | `handleException(SAXException e)` Handles checked SAXExceptions raised while emitting SAX events.
    `` | `protected void` | `nodeCompleted(Object parent, Object name)` Builder lifecycle callback invoked when the current node is complete.
    `` | `protected void` | `setParent(Object parent, Object child)` Builder lifecycle callback invoked after a child node has been created.

  - ### 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, setMetaClass`

- - ### Constructor Detail

    - #### public SAXBuilder(ContentHandler handler)

      Creates a builder that forwards markup events to the supplied SAX content handler.

      Parameters:
        `handler` - the content handler receiving generated SAX events

  - ### Method Detail

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

      Builder lifecycle callback that starts an element with no attributes or body text.

      Parameters:
        `name` - the node name
      Returns:
        the node marker used for subsequent callbacks

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

      Builder lifecycle callback that starts an element and immediately emits text content.

      Parameters:
        `name` - the node name
        `value` - the text content to emit
      Returns:
        the node marker used for subsequent callbacks

    - #### protected Object createNode(Object name, Map attributeMap, Object text)

      Builder lifecycle callback that starts an element, emits attributes and optionally emits text content.

      Parameters:
        `name` - the node name
        `attributeMap` - the attributes to expose through the SAX event
        `text` - the optional text content to emit after the start element
      Returns:
        the node marker used for subsequent callbacks

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

      Builder lifecycle callback that starts an element and emits attributes without body text.

      Parameters:
        `name` - the node name
        `attributes` - the attributes to expose through the SAX event
      Returns:
        the node marker used for subsequent callbacks

    - #### protected void doStartElement(Object name, Attributes attributes)

      Emits a SAX `startElement` event for the supplied node name. Subclasses may override to customize how start-element events are generated.

      Parameters:
        `name` - the node name
        `attributes` - the attributes to include with the start-element event

    - #### protected void handleException(SAXException e)

      Handles checked SAXExceptions raised while emitting SAX events. Subclasses may override to translate them differently.

      throws:
        RuntimeException by default, wrapping `e`
      Parameters:
        `e` - the SAX exception to handle

    - #### protected void nodeCompleted(Object parent, Object name)

      Builder lifecycle callback invoked when the current node is complete.

      Parameters:
        `parent` - the parent node marker
        `name` - the completed node name

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

      Builder lifecycle callback invoked after a child node has been created. This implementation is a no-op because parent relationships are expressed through SAX events.

      Parameters:
        `parent` - the parent node marker
        `child` - the child node marker