freemarker.core

## Class XMLOutputFormat

- java.lang.Object
- - freemarker.core.OutputFormat
  - - freemarker.core.MarkupOutputFormat<MO>
    - - freemarker.core.CommonMarkupOutputFormat<TemplateXMLOutputModel>
      - - freemarker.core.XMLOutputFormat

    public final class XMLOutputFormat
    extends CommonMarkupOutputFormat<TemplateXMLOutputModel>

Represents the XML output format (MIME type "application/xml", name "XML"). This format escapes by default (via `StringUtil.XMLEnc(String)`). The `?html`, `?xhtml` and `?xml` built-ins silently bypass template output values of the type produced by this output format (`TemplateXHTMLOutputModel`).

Since:
  2.3.24

### Field Summary

Fields
`static XMLOutputFormat` `INSTANCE` The only instance (singleton) of this `OutputFormat`.

### Method Summary

All Methods Instance Methods Concrete Methods
`String` `escapePlainText(String plainTextContent)` Should give the same result as `MarkupOutputFormat.fromPlainTextByEscaping(String)` and then `MarkupOutputFormat.getMarkupString(TemplateMarkupOutputModel)`, but the implementation may uses a more efficient solution.
`String` `getMimeType()` Returns the MIME type of the output format.
`String` `getName()` The short name used to refer to this format (like in the `#ftl` header).
`boolean` `isLegacyBuiltInBypassed(String builtInName)` Tells if a string built-in that can't handle a `TemplateMarkupOutputModel` left hand operand can bypass this object as is.
`protected TemplateXMLOutputModel` `newTemplateMarkupOutputModel(String plainTextContent, String markupContent)` Creates a new `CommonTemplateMarkupOutputModel` that's bound to this `OutputFormat` instance.
`void` `output(String textToEsc, Writer out)` Equivalent to calling `MarkupOutputFormat.fromPlainTextByEscaping(String)` and then `MarkupOutputFormat.output(TemplateMarkupOutputModel, Writer)`, but the implementation may uses a more efficient solution.

### Methods inherited from class freemarker.core.CommonMarkupOutputFormat

`concat, fromMarkup, fromPlainTextByEscaping, getMarkupString, getSourcePlainText, isAutoEscapedByDefault, isEmpty, isOutputFormatMixingAllowed, output`

### Methods inherited from class freemarker.core.OutputFormat

`toString, toStringExtraProperties`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### INSTANCE

    public static final XMLOutputFormat INSTANCE

The only instance (singleton) of this `OutputFormat`.

### Method Detail

#### getName

    public String getName()

Description copied from class: `OutputFormat`
The short name used to refer to this format (like in the `#ftl` header).

Specified by:
  `getName` in class `OutputFormat`

#### getMimeType

    public String getMimeType()

Description copied from class: `OutputFormat`
Returns the MIME type of the output format. This might comes handy when generating a HTTP response. `null` if this output format doesn't clearly corresponds to a specific MIME type.

Specified by:
  `getMimeType` in class `OutputFormat`

#### output

    public void output(String textToEsc,
                       Writer out)
                throws IOException,
                       TemplateModelException

Description copied from class: `MarkupOutputFormat`
Equivalent to calling `MarkupOutputFormat.fromPlainTextByEscaping(String)` and then `MarkupOutputFormat.output(TemplateMarkupOutputModel, Writer)`, but the implementation may uses a more efficient solution.

Specified by:
  `output` in class `CommonMarkupOutputFormat<TemplateXMLOutputModel>`
Throws:
  `IOException`
  `TemplateModelException`

#### escapePlainText

    public String escapePlainText(String plainTextContent)

Description copied from class: `MarkupOutputFormat`
Should give the same result as `MarkupOutputFormat.fromPlainTextByEscaping(String)` and then `MarkupOutputFormat.getMarkupString(TemplateMarkupOutputModel)`, but the implementation may uses a more efficient solution.

Specified by:
  `escapePlainText` in class `MarkupOutputFormat<TemplateXMLOutputModel>`

#### isLegacyBuiltInBypassed

    public boolean isLegacyBuiltInBypassed(String builtInName)

Description copied from class: `MarkupOutputFormat`
Tells if a string built-in that can't handle a `TemplateMarkupOutputModel` left hand operand can bypass this object as is. A typical such case would be when a `TemplateHTMLOutputModel` of "HTML" format bypasses `?html`.

Specified by:
  `isLegacyBuiltInBypassed` in class `MarkupOutputFormat<TemplateXMLOutputModel>`

#### newTemplateMarkupOutputModel

    protected TemplateXMLOutputModel newTemplateMarkupOutputModel(String plainTextContent,
                                                                  String markupContent)

Description copied from class: `CommonMarkupOutputFormat`
Creates a new `CommonTemplateMarkupOutputModel` that's bound to this `OutputFormat` instance.

Specified by:
  `newTemplateMarkupOutputModel` in class `CommonMarkupOutputFormat<TemplateXMLOutputModel>`