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

Re: Continuing problem. &NotaWhitespace;?

Subject: Re: Continuing problem. &NotaWhitespace;?
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 1 Nov 2001 18:42:21 +0000
xsl text empty string bug
Hi John,

> This is more like what I thought of, but this has the problem of
> that if the line contains several whitespaces in the beginning it
> will get *one* whitespace added to the beginning. It should have
> none in that case.

OK. I don't think you mentioned that requirement before. You're now
saying that if you have:

  <info><link>foo</link>    bar baz</info>

then you want it to give you:

  foo[1]bar baz

whereas if you have one whitespace character at the beginning of the
text node:

  <info><link>foo</link> bar baz</info>

then you want a space added to give you:

  foo[1] bar baz

Seems a bit strange, but OK. You need to test whether the second
character in the text node is a whitespace character. You can use:

  normalize-space(substring, 2, 1)

This will return false if the second character is whitespace because
normalizing a string that contains only whitespace gives the empty
string, which evaluates as false when it's converted to a boolean.

So the test would be:

  <xsl:if test="not(normalize-space(substring(., 1, 1))) and
                normalize-space(substring(., 2, 1))">
    <xsl:text> </xsl:text>
  </xsl:if>

I hope that's what you were after,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.