spring-framework / org.springframework.web.servlet.view.xslt / XsltView

XsltView

open class XsltView : AbstractUrlBasedView

XSLT-driven View that allows for response context to be rendered as the result of an XSLT transformation.

The XSLT Source object is supplied as a parameter in the model and then detected during response rendering. Users can either specify a specific entry in the model via the sourceKey property or have Spring locate the Source object. This class also provides basic conversion of objects into Source implementations. See here for more details.

All model parameters are passed to the XSLT Transformer as parameters. In addition the user can configure output properties to be passed to the Transformer.

Author
Rob Harrop

Author
Juergen Hoeller

Since
2.0

Constructors

<init>

XsltView()

XSLT-driven View that allows for response context to be rendered as the result of an XSLT transformation.

The XSLT Source object is supplied as a parameter in the model and then detected during response rendering. Users can either specify a specific entry in the model via the sourceKey property or have Spring locate the Source object. This class also provides basic conversion of objects into Source implementations. See here for more details.

All model parameters are passed to the XSLT Transformer as parameters. In addition the user can configure output properties to be passed to the Transformer.

Functions

setCacheTemplates

open fun setCacheTemplates(cacheTemplates: Boolean): Unit

Turn on/off the caching of the XSLT Templates instance.

The default value is "true". Only set this to "false" in development, where caching does not seriously impact performance.

setErrorListener

open fun setErrorListener(errorListener: ErrorListener): Unit

Set an implementation of the javax.xml.transform.ErrorListener interface for custom handling of transformation errors and warnings.

If not set, a default org.springframework.util.xml.SimpleTransformErrorListener is used that simply logs warnings using the logger instance of the view class, and rethrows errors to discontinue the XML transformation.

setIndent

open fun setIndent(indent: Boolean): Unit

Set whether the XSLT transformer may add additional whitespace when outputting the result tree.

Default is true (on); set this to false (off) to not specify an "indent" key, leaving the choice up to the stylesheet.

setOutputProperties

open fun setOutputProperties(outputProperties: Properties): Unit

Set arbitrary transformer output properties to be applied to the stylesheet.

Any values specified here will override defaults that this view sets programmatically.

setSourceKey

open fun setSourceKey(sourceKey: String): Unit

Set the name of the model attribute that represents the XSLT Source. If not specified, the model map will be searched for a matching value type.

The following source types are supported out of the box: Source, Document, Node, Reader, InputStream and Resource.

setTransformerFactoryClass

open fun setTransformerFactoryClass(transformerFactoryClass: Class<out TransformerFactory>): Unit

Specify the XSLT TransformerFactory class to use.

The default constructor of the specified class will be called to build the TransformerFactory for this view.

setUriResolver

open fun setUriResolver(uriResolver: URIResolver): Unit

Set the URIResolver used in the transform.

The URIResolver handles calls to the XSLT document() function.