This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Continuing problem. &NotaWhitespace;?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]