473,782 Members | 2,507 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XSL: Whitespace Problem With HTML Output

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="thisVa lidate()"> <xsl:attribut e
name="value">se lect</xsl:attribute>
</input>
<span style="width:5"/>
<input type="button" name="cancel" id="cancel" value="cancel">
<xsl:attribut e name="onClick"> window.navigate ('<xsl:value-of
select="$parent Page"/>?catid=<xsl:va lue-of
select="$catego ryId"/>')</xsl:attribute> </input>

Which outputs to HTML exactly like this:
<INPUT onClick="thisVa lidate()" 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('AddL ocalServicesByC ategory
?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

Jul 20 '05 #1
2 3540
Tempore 22:36:35, die Friday 28 January 2005 AD, hinc in foro {comp.text.xml} scripsit <jo*********@gm ail.com>:
Our XSL looks like this:
<input type="button" name="save" id="save"
onClick="thisVa lidate()"> <xsl:attribut e
name="value">se lect</xsl:attribute>
</input>
<span style="width:5"/>
<input type="button" name="cancel" id="cancel" value="cancel">
<xsl:attribut e name="onClick"> window.navigate ('<xsl:value-of
select="$parent Page"/>?catid=<xsl:va lue-of
select="$catego ryId"/>')</xsl:attribute> </input>

Which outputs to HTML exactly like this:
<INPUT onClick="thisVa lidate()" 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('AddL ocalServicesByC ategory
?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="normali ze-space($parentPa ge)"/>

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
Jul 20 '05 #2
That did it. Thanks!!

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3574
by: Derek Fountain | last post by:
When is the use of <xsl:text>blah blah</xsl:text> necessary? I'm finding that, although it's used religously in the book I'm learning from, if I miss it out, the output is just the same.
2
2021
by: f | last post by:
I am writing a java code generation tool. I use xml and xslt. But I have some problem using xsl:for-each. here is my xml <?xml version = "1.0"?> <CLASS package_name=".test" name="TestAnalysis" scope="public"> <ATTR name="tof" type="double" scope="public"/>
3
2230
by: StopBsod | last post by:
Hello group, I use XSLT to output a unix shell script based on the content of an XML file : The XSLT : <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text"/> <xsl:template name="haut" match="/rhythmdb">
3
6189
by: Gadrin77 | last post by:
I noticed when displaying the contents of a CDATA node inside a TEXTAREA using MSXML and XSL, I get an extra space before the data. at first I thought I hadn't "tightened up" the XSL, but then even when I did this... <textarea rows="24" cols="80"><xsl:value-of select="/Root/Child/Data"/></textarea>
2
4060
by: Angus Parvis | last post by:
Hi, I've already posted this in comp.lang.java.programmer, but it doesn't seem like the ppl there can help. I hope you guys here know more about it, altough my question is more java than xml related ;) Here's the problem: I have a XSL Stylesheet. Using the java.xml.transform.Transformer I transform XML to HTML. My XSL contains spaces and entities like
1
1812
by: Matt | last post by:
In XSL, if I want to make a whitespace, I put &nbsp; but not work. How to make a space?? The following won't create any spaces. It will output mytitlemyauthor <xsl:value-of select="title"> <xsl:value-of select="author"> But the following will output mytitle++myauthor: <xsl:value-of select="title">++<xsl:value-of select="author">
8
2941
by: Tjerk Wolterink | last post by:
Hello all, how does xsl handle white space? I know you can set domething like this for nice indentation: <xsl:output method="xhtml" indent="yes"/> But know i have xsl code like this:
8
1773
by: Matej Cepl | last post by:
Hello, does anybody have %subj%? I would like to generate some very simple HTML (XHTML?) file from OOImpress, so that I can send it to the friend for review and not bother her with all images, layouts, and the other junk (moreover, she probably never heard about OO.o). Powerpoint of the cursed memory used to have export of outline to RTF. Is there something similar for OOImpress (certainly, I do not care about RTF, OOWriter or HTML would...
2
1219
by: Simon M | last post by:
Hi, Hopefully someone can answer this; I am using aspx and c# to format XML using an XSL transform, the output is then written to the the response of the webform. When the page first loads the layout is not like it is described in the XSL... there is too much whitespace with gaps between things where there should be no gaps. If I save the html source and reopen it, it is as I want - formatted perfectly with no whitespace. If I load the...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10146
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9944
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.