[xsl] Re: Re: Fwd: Over/under trimming of whitespace

Subject: [xsl] Re: Re: Fwd: Over/under trimming of whitespace
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Fri, 26 Apr 2002 23:32:41 -0700 (PDT)
"David Morris" <David dot Morris at plumcreek dot com> wrote:

> Thank you for helping. I may be misinterpreting the XPATH spec, but
it
> 
> says "The normalize-space function returns the argument string with 
> whitespace normalized by stripping leading and trailing whitespace 
> and replacing sequences of whitespace characters by a single space."
> 
> I was expecting a single space and not an empty string - it
definitely
> 
> did this with Saxon, and I suspect that it does with Xalan but with
> Xalan 

The spec says that ***all*** leading/trailing whitespace should be
eliminated.

A whitespace-only node consists just of leading spaces, therefore after
space normalization its string-length must be zero.

And this is what really happens:

<xsl:stylesheet version="1.0" 
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:template match="/">
    <xsl:value-of select="string-length(normalize-space())"/>
  </xsl:template>
</xsl:stylesheet>

When applied on the following source xml:

<t xml:space="preserve">   </t>

it returns the following result:

<?xml version="1.0" encoding="utf-8"?>0


And this result is the same, when the transformation is performed with
Saxon, MSXML3, MSXML4.


Cheers,
Dimitre Novatchev.




__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com

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


Current Thread