Search in sources :

Example 1 with XMLOutputFormat

use of freemarker.core.XMLOutputFormat in project freemarker by apache.

the class Configuration method setOutputFormat.

/**
 * Sets the default output format. Usually, you should leave this on its default, which is
 * {@link UndefinedOutputFormat#INSTANCE}, and then use standard file extensions like "ftlh" (for HTML) or "ftlx"
 * (for XML) and ensure that {@link #setRecognizeStandardFileExtensions(boolean)} is {@code true} (see more there).
 * Where you can't use the standard extensions, templates still can be associated to output formats with
 * patterns matching their name (their path) using {@link #setTemplateConfigurations(TemplateConfigurationFactory)}.
 * But if all templates will have the same output format, you may use {@link #setOutputFormat(OutputFormat)} after
 * all, to a value like {@link HTMLOutputFormat#INSTANCE}, {@link XMLOutputFormat#INSTANCE}, etc. Also note
 * that templates can specify their own output format like {@code
 * <#ftl output_format="HTML">}, which overrides any configuration settings.
 *
 * <p>
 * The output format is mostly important because of auto-escaping (see {@link #setAutoEscapingPolicy(int)}), but
 * maybe also used by the embedding application to set the HTTP response MIME type, etc.
 *
 * @see #setRegisteredCustomOutputFormats(Collection)
 * @see #setTemplateConfigurations(TemplateConfigurationFactory)
 * @see #setRecognizeStandardFileExtensions(boolean)
 * @see #setAutoEscapingPolicy(int)
 *
 * @since 2.3.24
 */
public void setOutputFormat(OutputFormat outputFormat) {
    if (outputFormat == null) {
        throw new NullArgumentException("outputFormat", "You may meant: " + UndefinedOutputFormat.class.getSimpleName() + ".INSTANCE");
    }
    OutputFormat prevOutputFormat = getOutputFormat();
    this.outputFormat = outputFormat;
    outputFormatExplicitlySet = true;
    if (prevOutputFormat != outputFormat) {
        clearTemplateCache();
    }
}
Also used : UndefinedOutputFormat(freemarker.core.UndefinedOutputFormat) UndefinedOutputFormat(freemarker.core.UndefinedOutputFormat) CSSOutputFormat(freemarker.core.CSSOutputFormat) HTMLOutputFormat(freemarker.core.HTMLOutputFormat) CombinedMarkupOutputFormat(freemarker.core.CombinedMarkupOutputFormat) JavaScriptOutputFormat(freemarker.core.JavaScriptOutputFormat) OutputFormat(freemarker.core.OutputFormat) XMLOutputFormat(freemarker.core.XMLOutputFormat) MarkupOutputFormat(freemarker.core.MarkupOutputFormat) PlainTextOutputFormat(freemarker.core.PlainTextOutputFormat) XHTMLOutputFormat(freemarker.core.XHTMLOutputFormat) RTFOutputFormat(freemarker.core.RTFOutputFormat) JSONOutputFormat(freemarker.core.JSONOutputFormat) NullArgumentException(freemarker.template.utility.NullArgumentException)

Aggregations

CSSOutputFormat (freemarker.core.CSSOutputFormat)1 CombinedMarkupOutputFormat (freemarker.core.CombinedMarkupOutputFormat)1 HTMLOutputFormat (freemarker.core.HTMLOutputFormat)1 JSONOutputFormat (freemarker.core.JSONOutputFormat)1 JavaScriptOutputFormat (freemarker.core.JavaScriptOutputFormat)1 MarkupOutputFormat (freemarker.core.MarkupOutputFormat)1 OutputFormat (freemarker.core.OutputFormat)1 PlainTextOutputFormat (freemarker.core.PlainTextOutputFormat)1 RTFOutputFormat (freemarker.core.RTFOutputFormat)1 UndefinedOutputFormat (freemarker.core.UndefinedOutputFormat)1 XHTMLOutputFormat (freemarker.core.XHTMLOutputFormat)1 XMLOutputFormat (freemarker.core.XMLOutputFormat)1 NullArgumentException (freemarker.template.utility.NullArgumentException)1