Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Whitespace behaviour

From: "Dimitre Novatchev" <dimitren@---.---.-->
To: NULL
Date: 3/9/2006 6:28:00 AM
Why will it
> be zero space in the first, double space in the second and one space in 
> the third example?

Because by default white-space-only text nodes are stripped off by the MSXML 
parser and do not reach the XSLT processor.

In the second case you have &#xA; followed by a NL -- this is no longer a 
white-space-only text node and it is parsed successfully (not stripped). 
Then, when output by the msxml xslt processor, the browser displays both 
&#xA; and NL as spaces.

> I would like to do it like example2 since I will also add logic if fields 
> are empty etc (don't want to add a space if a field is empty) but I don't 
> want two spaces between the values.
>

then use:

<xsl:text>&#160;</xsl:text>



"Hans" <hans@n...> wrote in message 
news:%23hptzGpQGHA.4608@t......
> Hi!
>
> I'm trying to do an XML-->HTML transformation using XSL (presnting the 
> report in IE). I have a question about whitespace/linefeeds.
> If I in my xsl file have the following:
>
> <!--Example 1 -->
> <xsl:value-of select="Address"/>
> <xsl:value-of select="Zipcode"/>
> <xsl:value-of select="City"/>
> <xsl:value-of select="Country"/>
>
> all values are presented in one line without any spaces (or linefeeds).
>
> If I add a &nbsp; the space is doubled between values (still on one line)
>
> <!--Example 2 -->
> <xsl:value-of select="Address"/>&#160;
> <xsl:value-of select="Zipcode"/>&#160;
> <xsl:value-of select="City"/>&#160;
> <xsl:value-of select="Country"/>&#160;
>
>
> However if I put all in one line like
> <!--Example 3 -->
> <xsl:value-of select="Address"/>&#160;<xsl:value-of 
> select="Zipcode"/>&#160;<xsl:value-of select="City"/>&#160;<xsl:value-of 
> select="Country"/>&#160;
>
> there is just one space between the values which is what I want. Why will 
> it be zero space in the first, double space in the second and one space in 
> the third example?
>
> I would like to do it like example2 since I will also add logic if fields 
> are empty etc (don't want to add a space if a field is empty) but I don't 
> want two spaces between the values.
>
> Regards
> /Hans
>
> 




transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent