XSL: Whitespace Problem With HTML Output

josh.asbury

Usenet Archive
Joined
Jan 28, 2005
Messages
1
Reaction score
0
I am having some major issues with whitespace in my XSL stylesheets. We recently upgraded our servlet-based application to JDK 1.4, and this has forced the issue of my finally upgrading to Xalan-Java 2. The earlier version of Xalan was much more forgiving in regards to whitespace in our .xsl files, and now I am learning all about <xsl:text> and <xsl:strip-space>.

I've come across something with HTML buttons, though, that I can't find a way around.

Our XSL looks like this:
<input type="button" name="save" id="save"
onClick="thisValidate"> <xsl:attribute
name="value">select</xsl:attribute>
</input>
<span style="width:5"/>
<input type="button" name="cancel" id="cancel" value="cancel"> <xsl:attribute name="onClick">window.navigate('<xsl:value-of select="$parentPage"/>?catid=<xsl:value-of select="$categoryId"/>')</xsl:attribute> </input>

Which outputs to HTML exactly like this:
<INPUT onClick="thisValidate" id="save" name="save" type="button" value="select"><span style="width:5"></span><input value="cancel" id="cancel" name="cancel" type="button" onClick="window.navigate('AddLocalServicesByCategory

?catid=204194')">

I'm stumped. I've put <xsl:text/> in the window.navigate section. I've put <xsl:strip-space elements="*"/> in the stylesheet ( which, I think, shouldn't impact this behavior ).

Any insight or ideas on this would be greatly appreciated. I've got a ton of stylesheets behaving like this and need to have a solid go-forward plan in order to make this upgrade a success.

Thanks!
Josh
 

Joris Gillis

Usenet Archive
Joined
Sep 28, 2004
Messages
355
Reaction score
0
Tempore 22:36:35 said:
Our XSL looks like this:
<input type="button" name="save" id="save"
onClick="thisValidate"> <xsl:attribute
name="value">select</xsl:attribute>
</input>
<span style="width:5"/>
<input type="button" name="cancel" id="cancel" value="cancel"> <xsl:attribute name="onClick">window.navigate('<xsl:value-of select="$parentPage"/>?catid=<xsl:value-of select="$categoryId"/>')</xsl:attribute> </input>

Which outputs to HTML exactly like this:
<INPUT onClick="thisValidate" id="save" name="save" type="button" value="select"><span style="width:5"></span><input value="cancel" id="cancel" name="cancel" type="button" onClick="window.navigate('AddLocalServicesByCategory

?catid=204194')">

I'm stumped. I've put <xsl:text/> in the window.navigate section. I've put <xsl:strip-space elements="*"/> in the stylesheet ( which, I think, shouldn't impact this behavior ).
well, in fact it does not. The 'strip-space' element tells the XSLT processor to omit text nodes that contain nothing but whitespaces.

It seems the problem lies with the 'parentPage' variable; it contains linebreaks. You can trim the whitespaces with the 'normalize-space':
<xsl:value-of select="normalize-space($parentPage)"/>

Better would be to prohibit the linebreaks from being added at all when you create the variable.

regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,049
Messages
3,104,244
Members
248,133
Latest member
DujonT

Latest Threads

Top