Save This Page
Home » spring-framework-2.5.5-with-dependencies » org.springframework » web » servlet » view » xslt » [javadoc | source]
org.springframework.web.servlet.view.xslt
abstract public class: AbstractXsltView [javadoc | source]
java.lang.Object
   org.springframework.context.support.ApplicationObjectSupport
      org.springframework.web.context.support.WebApplicationObjectSupport
         org.springframework.web.servlet.view.AbstractView
            org.springframework.web.servlet.view.xslt.AbstractXsltView

All Implemented Interfaces:
    View, BeanNameAware, ServletContextAware, ApplicationContextAware

Convenient superclass for views rendered using an XSLT stylesheet.

Subclasses typically must provide the Source to transform by overriding #createXsltSource . Subclasses do not need to concern themselves with XSLT other than providing a valid stylesheet location.

Properties:

Note that setting "cache" to false will cause the template objects to be reloaded for each rendering. This is useful during development, but will seriously affect performance in production and is not thread-safe.

Field Summary
public static final  String XML_CONTENT_TYPE    The default content type if no stylesheet specified 
public static final  String DEFAULT_ROOT    The default document root name 
Fields inherited from org.springframework.web.servlet.view.AbstractView:
DEFAULT_CONTENT_TYPE
Fields inherited from org.springframework.context.support.ApplicationObjectSupport:
logger
Constructor:
 protected AbstractXsltView() 
Method from org.springframework.web.servlet.view.xslt.AbstractXsltView Summary:
applyTransformerParameters,   buildTransformer,   createXsltSource,   doTransform,   doTransform,   getParameters,   getParameters,   getParameters,   getStylesheetLocation,   getStylesheetSource,   getTemplates,   getTransformerFactory,   initApplicationContext,   newTransformerFactory,   renderMergedOutputModel,   resetCachedTemplates,   setCache,   setContentType,   setErrorListener,   setIndent,   setOutputProperties,   setRoot,   setStylesheetLocation,   setTransformerFactoryClass,   setUriResolver,   setUseSingleModelNameAsRoot,   useWriter
Methods from org.springframework.web.servlet.view.AbstractView:
addStaticAttribute,   createRequestContext,   createTemporaryOutputStream,   exposeModelAsRequestAttributes,   generatesDownloadContent,   getAttributesMap,   getBeanName,   getContentType,   getRequestContextAttribute,   getStaticAttributes,   prepareResponse,   render,   renderMergedOutputModel,   setAttributes,   setAttributesCSV,   setAttributesMap,   setBeanName,   setContentType,   setRequestContextAttribute,   toString,   writeToResponse
Methods from org.springframework.web.context.support.WebApplicationObjectSupport:
getServletContext,   getTempDir,   getWebApplicationContext,   initApplicationContext,   initServletContext,   isContextRequired,   setServletContext
Methods from org.springframework.context.support.ApplicationObjectSupport:
getApplicationContext,   getMessageSourceAccessor,   initApplicationContext,   initApplicationContext,   isContextRequired,   requiredContextClass,   setApplicationContext
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.springframework.web.servlet.view.xslt.AbstractXsltView Detail:
 protected  void applyTransformerParameters(Map parameters,
    Transformer transformer) 
    Apply the specified parameters to the given Transformer.
 protected Transformer buildTransformer(Map parameters) throws TransformerConfigurationException 
    Build a Transformer object for immediate use, based on the given parameters.
 protected Source createXsltSource(Map model,
    String root,
    HttpServletRequest request,
    HttpServletResponse response) throws Exception 
    Return the XML Source to transform.
 protected  void doTransform(Map model,
    Source source,
    HttpServletRequest request,
    HttpServletResponse response) throws Exception 
 protected  void doTransform(Source source,
    Map parameters,
    Result result,
    String encoding) throws Exception 
    Perform the actual transformation, writing to the given result.
 protected Map getParameters() 
Deprecated! as - of Spring 2.0.4, in favor of the #getParameters(HttpServletRequest) variant

    Return a Map of transformer parameters to be applied to the stylesheet.
 protected Map getParameters(HttpServletRequest request) 
    Return a Map of transformer parameters to be applied to the stylesheet.

    Subclasses can override this method in order to apply one or more parameters to the transformation process.

    The default implementation delegates to the simple #getParameters() variant.

 protected Map getParameters(Map model,
    HttpServletRequest request) 
    Return a Map of transformer parameters to be applied to the stylesheet.

    Subclasses can override this method in order to apply one or more parameters to the transformation process.

    The default implementation delegates to the #getParameters(HttpServletRequest) variant.

 protected Resource getStylesheetLocation() 
    Return the location of the XSLT stylesheet, if any.
 protected Source getStylesheetSource(Resource stylesheetLocation) throws ApplicationContextException 
    Load the stylesheet from the specified location.
 protected Templates getTemplates() throws TransformerConfigurationException 
    Obtain the Templates object to use, based on the configured stylesheet, either a cached one or a freshly built one.

    Subclasses may override this method e.g. in order to refresh the Templates instance, calling #resetCachedTemplates() before delegating to this getTemplates() implementation.

 protected final TransformerFactory getTransformerFactory() 
    Return the TransformerFactory used by this view. Available once the View object has been fully initialized.
 protected final  void initApplicationContext() throws ApplicationContextException 
 protected TransformerFactory newTransformerFactory(Class transformerFactoryClass) 
 protected final  void renderMergedOutputModel(Map model,
    HttpServletRequest request,
    HttpServletResponse response) throws Exception 
 public final  void resetCachedTemplates() 
    Reset the cached Templates object, if any.

    The Templates object will subsequently be rebuilt on next access , if caching is enabled.

 public  void setCache(boolean cache) 
    Set whether to activate the template cache for this view.

    Default is true. Turn this off to refresh the Templates object on every access, e.g. during development.

 public  void setContentType(String contentType) 
 public  void setErrorListener(ErrorListener errorListener) 
 public  void setIndent(boolean indent) 
    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.

 public  void setOutputProperties(Properties outputProperties) 
    Set arbitrary transformer output properties to be applied to the stylesheet.

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

 public  void setRoot(String root) 
    The document root element name. Default is "DocRoot" .

    Only used if we're not passed a single Node as the model.

 public  void setStylesheetLocation(Resource stylesheetLocation) 
    Set the location of the XSLT stylesheet.

    If the TransformerFactory used by this instance has already been initialized then invoking this setter will result in the attendant templates being re-cached.

 public  void setTransformerFactoryClass(Class transformerFactoryClass) 
    Specify the XSLT TransformerFactory class to use.

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

 public  void setUriResolver(URIResolver uriResolver) 
    Set the URIResolver used in the transform.

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

 public  void setUseSingleModelNameAsRoot(boolean useSingleModelNameAsRoot) 
    Set whether to use the name of a given single model object as the document root element name.

    Default is true : If you pass in a model with a single object named "myElement", then the document root will be named "myElement" as well. Set this flag to false if you want to pass in a single model object while still using the root element name configured through the "root" property .

 protected boolean useWriter() 
    Return whether to use a java.io.Writer to write text content to the HTTP response. Else, a java.io.OutputStream will be used, to write binary content to the response.

    The default implementation returns false, indicating a a java.io.OutputStream.