StaxBuilder (Groovy 5.0.0)

Package: groovy.xml

## [Groovy] Class StaxBuilder

- groovy.xml.StaxBuilder

-     class StaxBuilder
      extends BuilderSupport

  A Groovy builder that works with Stax processors. A typical usage is as follows:

       import javax.xml.stream.XMLOutputFactory
       def factory = XMLOutputFactory.newInstance()
       def writer = new StringWriter()
       def builder = new groovy.xml.StaxBuilder(factory.createXMLStreamWriter(writer))
       builder.root1(a:5, b:7) {
           elem1('hello1')
           elem2('hello2')
           elem3(x:7)
       }
       assert writer.toString() == 'hello1hello2'

  Or an external library such as Jettison can be used as follows:

       @Grab('org.codehaus.jettison:jettison:1.2')
       import org.codehaus.jettison.mapped.*
       import javax.xml.stream.XMLStreamException

       def conv = new MappedNamespaceConvention()
       def writer = new StringWriter()
       def mappedWriter = new MappedXMLStreamWriter(conv, writer)
       def builder = new groovy.xml.StaxBuilder(mappedWriter)
       builder.root1(a:5, b:7) {
           elem1('hello1')
           elem2('hello2')
           elem3(x:7)
       }
       assert writer.toString() == '''{"root1":{"@a":"5","@b":"7","elem1":"hello1","elem2":"hello2","elem3":{"@x":"7"}}}'''

- - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `Object` | `writer`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `StaxBuilder(Object xmlStreamWriter)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `protected Object` | `createNode(Object name)`
    `` | `protected Object` | `createNode(Object name, Object value)`
    `` | `protected Object` | `createNode(Object name, Map attributes)`
    `` | `protected Object` | `createNode(Object name, Map attributes, Object value)`
    `` | `protected void` | `nodeCompleted(Object parent, Object node)`
    `` | `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, setMetaClass`

- - ### Property Detail

    - #### Object writer

  - ### Constructor Detail

    - #### StaxBuilder(Object xmlStreamWriter)

  - ### Method Detail

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

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

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

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

    - #### @SuppressWarnings(value: UnusedMethodParameter)
      protected void nodeCompleted(Object parent, Object node)

    - #### @SuppressWarnings(value: [UnusedMethodParameter, EmptyMethod])
      protected void setParent(Object parent, Object child)