org.carrot2.util.xsltfilter
Class XSLTFilter

java.lang.Object
  extended by org.carrot2.util.xsltfilter.XSLTFilter
All Implemented Interfaces:
javax.servlet.Filter

public final class XSLTFilter
extends Object
implements javax.servlet.Filter

A servlet filter applying XSLT stylesheets to the result of a request. The filter is activated when the content has a MIME type equal to text/xml AND:

  1. the content has a correct ext-stylesheet directive (custom extension) OR,
  2. the content has a correct xml-stylesheet directive,
  3. processing has not been suppressed by setting XSLTFilterConstants.NO_XSLT_PROCESSING in the request context.
Filter configuration is given through the web application descriptor file (web.xml).

Example configuration using ext-stylesheet:

 <?ext-stylesheet resource="WEB-INF/stylesheets/stylesheet.xsl" ?> 
 

Example configuration using xml-stylesheet (note the URL here is servlet-container relative, not application-context relative):

 <?xml-stylesheet type="text/xsl" href="/stylesheets/stylesheet.xsl" ?> 
 


Constructor Summary
XSLTFilter()
           
 
Method Summary
 void destroy()
          Take this filter out of service.
 void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)
          Apply the XSLT stylesheet to the response and pass the result to the next filter.
 void init(javax.servlet.FilterConfig filterConfig)
          Place this filter into service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XSLTFilter

public XSLTFilter()
Method Detail

init

public void init(javax.servlet.FilterConfig filterConfig)
          throws javax.servlet.ServletException
Place this filter into service.

Specified by:
init in interface javax.servlet.Filter
Parameters:
filterConfig - The filter configuration object
Throws:
javax.servlet.ServletException

destroy

public void destroy()
Take this filter out of service.

Specified by:
destroy in interface javax.servlet.Filter

doFilter

public void doFilter(javax.servlet.ServletRequest request,
                     javax.servlet.ServletResponse response,
                     javax.servlet.FilterChain chain)
              throws IOException,
                     javax.servlet.ServletException
Apply the XSLT stylesheet to the response and pass the result to the next filter.

Specified by:
doFilter in interface javax.servlet.Filter
Throws:
IOException
javax.servlet.ServletException


Copyright (c) Dawid Weiss, Stanislaw Osinski