This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: newline white space
- To: "Lisa Rupe" <LRupe at questia dot com>
- Subject: Re: [xsl] newline white space
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Fri, 20 Jul 2001 10:58:57 +0100
- CC: xsl-list at lists dot mulberrytech dot com
- Organization: Jeni Tennison Consulting Ltd
- References: <OF06939A25.CA75FCD6-ON86256A8F.00073AAA@questia.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
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