I needed an XSLT filter for a long time. These few solutions you can find on the Web are usually
very simple — buffering of the servlet's output and preprocessing with a given XSLT stylesheet.
My goal was to create something more advanced — a production-quality XSLT filter which could
preprocess XML files with various xml-stylesheet directives, output methods and encodings, take
into consideration processing errors and such. This is the result.

How to use it?

Define the filter in Web application descriptor (web.xml) and map it to any extension which should
be processed. Something like this should do: