Overview | Package | Class
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## groovy.xml
Class MarkupBuilder

A helper class for creating XML or HTML markup

author:
  James Strachan

author:
  Stefan Matthias Aust

author:
  Scott Stirling

author:
  Paul King

version:
  $Revision: 12949 $

Field Summary
`boolean` | `nodeIsEmpty`
`boolean` | `nospace`
`boolean` | `omitEmptyAttributes`
`boolean` | `omitNullAttributes`
`IndentPrinter` | `out`
`int` | `state`
`boolean` | `useDoubleQuotes`

Constructor Summary
`MarkupBuilder()`
`MarkupBuilder(PrintWriter writer)`
`MarkupBuilder(Writer writer)`
`MarkupBuilder(IndentPrinter out)`

Method Summary
`Object` | `createNode(Object name)`
`Object` | `createNode(Object name, Object value)`
`Object` | `createNode(Object name, Map attributes, Object value)`
`Object` | `createNode(Object name, Map attributes)`
`String` | `escapeAttributeValue(String value)` Escapes a string so that it can be used directly as an XML attribute value.
`String` | `escapeElementContent(String value)` Escapes a string so that it can be used directly in XML element content.
`String` | `escapeXmlValue(String value, boolean isAttrValue)` Escapes a string so that it can be used in XML text successfully.
`boolean` | `getDoubleQuotes()` Returns `true` if attribute values are output with double quotes; `false` if single quotes are used.
`Object` | `getMkp()`
`Object` | `getName(String methodName)`
`IndentPrinter` | `getPrinter()`
`boolean` | `isOmitEmptyAttributes()` Determine whether empty attributes will appear in the produced markup.
`boolean` | `isOmitNullAttributes()` Determine whether null attributes will appear in the produced markup.
`void` | `nodeCompleted(Object parent, Object node)`
`void` | `print(Object node)`
`void` | `setDoubleQuotes(boolean useDoubleQuotes)` Sets whether the builder outputs attribute values in double quotes or single quotes.
`void` | `setOmitEmptyAttributes(boolean omitEmptyAttributes)` Allows empty attributes to be removed the produced markup.
`void` | `setOmitNullAttributes(boolean omitNullAttributes)` Allows null attributes to be removed the produced markup.
`void` | `setParent(Object parent, Object child)`
`void` | `toState(int next, Object name)`
`String` | `transformValue(String value)` Returns a String with special XML characters escaped as entities so that output XML is valid.
`void` | `yield(String value)`
`void` | `yield(String value, boolean escaping)`
`void` | `yieldUnescaped(String value)`

Constructor Detail

### MarkupBuilder

    public MarkupBuilder()

### MarkupBuilder

    public MarkupBuilder(PrintWriter writer)

### MarkupBuilder

    public MarkupBuilder(Writer writer)

### MarkupBuilder

    public MarkupBuilder(IndentPrinter out)

Method Detail

### createNode

    Object createNode(Object name)

### createNode

    Object createNode(Object name, Object value)

### createNode

    Object createNode(Object name, Map attributes, Object value)

### createNode

    Object createNode(Object name, Map attributes)

### escapeAttributeValue

    String escapeAttributeValue(String value)

  Escapes a string so that it can be used directly as an XML attribute value.
  param:
    value The string to escape.
  return:
    A new string in which all characters that require escaping
  have been replaced with the corresponding XML entities.
  see:
    #escapeXmlValue(String, boolean)

### escapeElementContent

    String escapeElementContent(String value)

  Escapes a string so that it can be used directly in XML element content.
  param:
    value The string to escape.
  return:
    A new string in which all characters that require escaping
  have been replaced with the corresponding XML entities.
  see:
    #escapeXmlValue(String, boolean)

### escapeXmlValue

    String escapeXmlValue(String value, boolean isAttrValue)

  Escapes a string so that it can be used in XML text successfully. It replaces the following characters with the corresponding XML entities:
  - & as &amp;
  - < as &lt;
  - > as &gt;
  If the string is to be added as an attribute value, these characters are also escaped:
  - ' as &apos;
  param:
    value The string to escape.
  param:
    isAttrValue `true` if the string is to be used
  as an attribute value, otherwise `false`.
  return:
    A new string in which all characters that require escaping
  have been replaced with the corresponding XML entities.

### getDoubleQuotes

    public boolean getDoubleQuotes()

  Returns `true` if attribute values are output with double quotes; `false` if single quotes are used. By default, single quotes are used.
  return:
    true if double quotes are used for attributes

### getMkp

    public Object getMkp()

### getName

    Object getName(String methodName)

### getPrinter

    IndentPrinter getPrinter()

### isOmitEmptyAttributes

    public boolean isOmitEmptyAttributes()

  Determine whether empty attributes will appear in the produced markup.
  return:
    `true`, if empty attributes will be
  removed from the resulting markup.

### isOmitNullAttributes

    public boolean isOmitNullAttributes()

  Determine whether null attributes will appear in the produced markup.
  return:
    `true`, if null attributes will be
  removed from the resulting markup.

### nodeCompleted

    void nodeCompleted(Object parent, Object node)

### print

    void print(Object node)

### setDoubleQuotes

    public void setDoubleQuotes(boolean useDoubleQuotes)

  Sets whether the builder outputs attribute values in double quotes or single quotes.
  param:
    useDoubleQuotes If this parameter is `true`,
  double quotes are used; otherwise, single quotes are.

### setOmitEmptyAttributes

    public void setOmitEmptyAttributes(boolean omitEmptyAttributes)

  Allows empty attributes to be removed the produced markup.
  param:
    omitEmptyAttributes if `true`, empty
  attributes will not be included in the resulting markup. Defaults to `false`.

### setOmitNullAttributes

    public void setOmitNullAttributes(boolean omitNullAttributes)

  Allows null attributes to be removed the produced markup.
  param:
    omitNullAttributes if `true`, null
  attributes will not be included in the resulting markup. If `false` null attributes will be included in the markup as empty strings regardless of the omitEmptyAttribute setting. Defaults to `false`.

### setParent

    void setParent(Object parent, Object child)

### toState

    void toState(int next, Object name)

### transformValue

    String transformValue(String value)

  Returns a String with special XML characters escaped as entities so that output XML is valid. Escapes the following characters as corresponding entities:
  - \' as &apos;
  - & as &amp;
  - < as &lt;
  - > as &gt;
  param:
    value to be searched and replaced for XML special characters.
  return:
    value with XML characters escaped
  deprecated:
    @see #escapeXmlValue(String, boolean)

### yield

    public void yield(String value)

### yield

    void yield(String value, boolean escaping)

### yieldUnescaped

    public void yieldUnescaped(String value)