Subject: Re: newline white space
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Fri, 20 Jul 2001 10:58:57 +0100
|
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(' 
	
', 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) <=
|
|