Package groovy.xml

Class SerializeOptions

java.lang.Object
groovy.xml.SerializeOptions

public class SerializeOptions extends Object
Options for controlling XML serialization via XmlUtil.serialize(org.w3c.dom.Element).

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 Details

    • SerializeOptions

      public SerializeOptions()
  • Method Details

    • getEncoding

      public String getEncoding()
      The character encoding for the XML output. Default is "UTF-8".
      Returns:
      the encoding name
    • setEncoding

      public void setEncoding(String encoding)
    • getCharset

      public Charset getCharset()
      The character encoding as a Charset.
      Returns:
      the Charset for the configured encoding
    • getIndent

      public int getIndent()
      The number of spaces to use for indentation. Default is 2.
      Returns:
      the indent amount
    • setIndent

      public void setIndent(int indent)
    • isAllowDocTypeDeclaration

      public boolean isAllowDocTypeDeclaration()
      Whether to allow DOCTYPE declarations during serialization. Default is false.
      Returns:
      true if DOCTYPE declarations are allowed
    • setAllowDocTypeDeclaration

      public void setAllowDocTypeDeclaration(boolean allowDocTypeDeclaration)