views:

97

answers:

1

I have a function that transforms XML according to a XSLT. To test it, I'm using it in a jsp but it's entering a lot of breaks before my output. It seems to be the breaks I enter when setting variables:

<c:set var="blah" value="blah" />
<c:set var="blah2" value="blah2" />

That will show two line breaks before the output. Is there a way to avoid this with XML? I tried adding trimDirectiveWhitespaces="true" but it didn't help.

A: 

If you are using Tomcat to parse your jsp, you can have a go with:

<init-param>
    <param-name>trimSpaces</param-name>
    <param-value>true</param-value>
</init-param>

In your web.xml. YMMV

Else, I think that JSP 2.1 supports the following:

<%@ page trimDirectiveWhitespaces="true" %>

The last solution is any of this doesn't work is to implement a filter between your JSP rendering and your XSLT computation. A simple filter can be called to trim the spaces around the generated body.

Oct