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

Re: newline white space

Subject: Re: newline white space
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Fri, 20 Jul 2001 10:58:57 +0100
new line whitespace
Hi Lisa,

> This solved my problem for the hyphenated words, but where ever
> there were other tags in the string, I lost my spaces.
> How can I fix this?

Don't normalise the text nodes ;) Get rid of the normalising template
that I suggested (sorry):

<xsl:template match="text()">
  <xsl:value-of select="normalize-space()" />
</xsl:template>

and instead have a template that only matches text nodes that
immediately follow a lb element:

<xsl:template match="text()[preceding-sibling::*[1][self::lb]">
  ...
</xsl:template>

I don't know whether all these text nodes start with a new line? If
so, then you could just remove that first new line character:

<xsl:template match="text()[preceding-sibling::*[1][self::lb]">
  <xsl:value-of select="substring(., 2)" />
</xsl:template>

Otherwise, you need to test whether the first character is a
whitespace character, in which case you want to ignore it (otherwise
you just give the value of the text node):

<xsl:template match="text()[preceding-sibling::*[1][self::lb]">
  <xsl:choose>
    <xsl:when test="contains(' &#xA;&#x9;&#xD;', substring(., 1, 1))">
      <xsl:value-of select="substring(., 2)" />
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="." />
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

Cheers,

Jeni

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


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


Current Thread
  • newline white space
    • Lisa Rupe - Thu, 19 Jul 2001 12:40:51 -0400 (EDT)
      • <Possible follow-ups>
      • Lisa Rupe - Thu, 19 Jul 2001 21:32:18 -0400 (EDT)
        • Jeni Tennison - Fri, 20 Jul 2001 06:02:30 -0400 (EDT) <=

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.