Package: groovy.xml

## [Java] Class SerializeOptions

- groovy.xml.SerializeOptions

-     public class SerializeOptions
      extends Object

  Options for controlling XML serialization via XmlUtil.serialize.

  All options have sensible defaults matching the existing behaviour of `XmlUtil.serialize()`, so only options that need to differ from the defaults need to be specified:

       // Groovy named parameters:
       XmlUtil.serialize(node, new SerializeOptions(encoding: 'ISO-8859-1', indent: 4))

  Since:
    6.0.0

- - ### Constructor Summary

    Constructors
    Constructor and description
    `SerializeOptions()` Creates a new options instance using the default serialization settings.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public Charset` | `getCharset()` The character encoding as a Charset.
    `` | `public String` | `getEncoding()` The character encoding for the XML output.
    `` | `public int` | `getIndent()` The number of spaces to use for indentation.
    `` | `public boolean` | `isAllowDocTypeDeclaration()` Whether to allow DOCTYPE declarations during serialization.
    `` | `public boolean` | `isAllowExternalResources()` Whether the underlying TransformerFactory may resolve external DTDs and stylesheets (e.g. via `<xsl:import>` or `<xsl:include>`).
    `` | `public void` | `setAllowDocTypeDeclaration(boolean allowDocTypeDeclaration)` Sets whether DOCTYPE declarations are allowed during serialization.
    `` | `public void` | `setAllowExternalResources(boolean allowExternalResources)` Sets whether external DTDs and stylesheets may be resolved during serialization.
    `` | `public void` | `setEncoding(String encoding)` Sets the character encoding for the XML output.
    `` | `public void` | `setIndent(int indent)` Sets the number of spaces to use for indentation.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### public SerializeOptions()

      Creates a new options instance using the default serialization settings.

  - ### Method Detail

    - #### public Charset getCharset()

      The character encoding as a Charset.

      Returns:
        the Charset for the configured encoding

    - #### public String getEncoding()

      The character encoding for the XML output. Default is `"UTF-8"`.

      Returns:
        the encoding name

    - #### public int getIndent()

      The number of spaces to use for indentation. Default is `2`.

      Returns:
        the indent amount

    - #### public boolean isAllowDocTypeDeclaration()

      Whether to allow DOCTYPE declarations during serialization. Default is `false`.

      Returns:
        true if DOCTYPE declarations are allowed

    - #### public boolean isAllowExternalResources()

      Whether the underlying TransformerFactory may resolve external DTDs and stylesheets (e.g. via `<xsl:import>` or `<xsl:include>`). Default is `false`; set to `true` when serializing XSLT documents that legitimately reference external resources.

      Returns:
        `true` if external resource resolution is allowed
      Since:
        6.0.0

    - #### public void setAllowDocTypeDeclaration(boolean allowDocTypeDeclaration)

      Sets whether DOCTYPE declarations are allowed during serialization.

      Parameters:
        `allowDocTypeDeclaration` - `true` to allow DOCTYPE declarations

    - #### public void setAllowExternalResources(boolean allowExternalResources)

      Sets whether external DTDs and stylesheets may be resolved during serialization.

      Parameters:
        `allowExternalResources` - `true` to allow external resource resolution
      Since:
        6.0.0

    - #### public void setEncoding(String encoding)

      Sets the character encoding for the XML output.

      Parameters:
        `encoding` - the encoding name to use

    - #### public void setIndent(int indent)

      Sets the number of spaces to use for indentation.

      Parameters:
        `indent` - the indent amount