I have a servlet filter in my application that intercepts all the incoming requests and tries to strip the whitespaces from the incoming XML and write the resulting \'clean\
It is not clear what you intend to get as an output, and what you expect from xsl:strip-whitespace in the first place. But one thing to note is that it doesn't strip all whitespace, but only that which is deemed insignificant under the "usual" rules. In particular, from XSLT 1.0 spec:
A text node is never stripped unless it contains only whitespace characters.
So, for example, this:
will be stripped down to:
because it had 3 whitespace-only text nodes (after and before , between and , and after and before ).
Note also that because you have in your stylesheet, it will end up being transformed to:
in the output.
On the other hand, this:
text1
text2
text3
Will not be stripped at all, because all text nodes it contains are not purely whitespace nodes.