This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Continuing problem. &NotaWhitespace;?
On Nov 01 16:20, Jeni Tennison wrote:
> Ah. OK, then you need the info template to just apply templates to
> all its children as before, and you need to do some clever business
> within the text() template to work out what to do. I think that the
> rules are that it should emit the normalized string, plus:
>
> * a space before the normalized string if there is a normalized
> string and the original string had whitespace as its first
> character
>
> * a space after the normalized string if there is a normalized
> string and the original string had whitespace as its last
> character
>
> This gives you a template like:
>
> <xsl:template match="text()">
> <xsl:variable name="normalizedString" select="normalize-space()" />
> <xsl:if test="not(normalize-space(substring(., 1, 1)))">
> <xsl:text> </xsl:text>
> </xsl:if>
> <xsl:value-of select="$normalizedString" />
> <xsl:if test="not(normalize-space(substring(., string-length())))">
> <xsl:text> </xsl:text>
> </xsl:if>
> </xsl:template>
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.
Instead of the code on line 3:
<xsl:if test="not(normalize-space(substring(., 1, 1)))">
I would like to write something like this:
<xsl:if test="contains(substring(., 1, 2),' &NotaWhitespace;')">
Where &NotaWhiteSpace; is some wildcard that includes every letter except
whitespace and newline. Does it exist something like that?
This would put *one* whitespace infront of the line who begins with *one*
whitespace, not several.
--
* John Ericson john@john.pp.se
* ICQ: 7325429 JID: high@jabber.org
* web: http://john.pp.se
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list