Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XSL: Whitespace Problem With HTML Output

Reply
Thread Tools

XSL: Whitespace Problem With HTML Output

 
 
josh.asbury@gmail.com
Guest
Posts: n/a
 
      01-28-2005
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('AddLocalServicesByCatego ry


?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

 
Reply With Quote
 
 
 
 
Joris Gillis
Guest
Posts: n/a
 
      01-29-2005
Tempore 22:36:35, die Friday 28 January 2005 AD, hinc in foro {comp.text.xml} scripsit <(E-Mail Removed)>:

> 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('AddLocalServicesByCatego ry
>
>
> ?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,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
"Et ipsa scientia potestas est" - Francis Bacon , Meditationes sacrae
 
Reply With Quote
 
 
 
 
Josh
Guest
Posts: n/a
 
      01-31-2005
That did it. Thanks!!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Splitting text at whitespace but keeping the whitespace in thereturned list MRAB Python 3 01-26-2010 11:36 PM
Structure using whitespace vs logical whitespace cmdrrickhunter@yaho.com Python 10 12-16-2008 03:51 PM
Problems with whitespace in output document Michael Kragh Pedersen XML 1 03-14-2005 09:43 PM
Whitespace where I don't want whitespace! Oli Filth HTML 9 01-17-2005 08:47 PM
controlling whitespace with output method=html Andy Fish XML 2 06-15-2004 06:08 AM



Advertisments