[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: White space in HTML result??

Subject: Re: White space in HTML result??
From: Mike Brown <mike@xxxxxxxx>
Date: Mon, 5 Feb 2001 21:49:43 -0700 (MST)
non breaking space textnode
> <a>
> [...]
> </a>&#160;&#160;
>            </xsl:for-each>
> The problem is, after each </a> in the HTML page, there is x number of
> spaces.

Well this is expected, because after the 'a' element you have 2
non-whitespace characters and then a newline which is whitespace
and some spaces or tabs, which are also whitespace. Yes, I know
non-breaking spaces look like whitespace, but they aren't really.

The XPath/XSLT tree model insists that all adjacent text becomes
one text node, so you've got a text node containing all that text,
starting with the 2 non-breaking spaces. 

The model says that if the text node is nothing but whitespace,
it might be removed from the tree ('stripped') prior to processing.
If it's in the stylesheet it will always be stripped and you have
no control over this. If it's in the source tree, you have some
control that I won't go into here..

But this is academic since your text node is not purely whitespace.
This means you are stuck with it!

You just need to get the non-breaking spaces into a text node by
themselves. This will do it:

   <xsl:for-each ...>

Just be aware that it's not the fact that <xsl:text> is being used;
it's the fact that the non-breaking spaces are contained inside
*some* element, separate from the whitespace that comes at the end
of the contents of the xsl:for-each element.

   - Mike
Mike J. Brown, software engineer at            My XML/XSL resources: 
webb.net in Denver, Colorado, USA              http://skew.org/xml/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.