|
Subject: Re: [xsl] Tokenizing IDREFs From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Thu, 20 Sep 2001 16:48:12 +0100 |
Hi Stuart,
> However, this clearly only functions where the IDREFs are delimited
> by a single space. I am trying to construct a transformation which
> will work if the IDREFs are delimited by EITHER a single space OR a
> line-break, but to absolutely no success. Any pointers, please?
The easiest thing is to normalize the whitespace in the string before
you pass it to your tokenize template - this will strip leading and
trailing whitespace and convert any consecutive whitespace characters
(including line breaks) into single spaces. And it has the advantage
of being a fairly simple change to your existing template:
<xsl:template match="inTag">
<xsl:variable name="value" select="normalize-space(@value)" />
<xsl:choose>
<xsl:when test="contains($value,' ')">
<bag>
<xsl:call-template name="tokenize">
<xsl:with-param name="string" select="$value" />
</xsl:call-template>
</bag>
</xsl:when>
<xsl:otherwise>
<outTag value="{$value}"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
[Note that for simplicity I've used the select attribute of
xsl:with-param rather than its content, so that it's set to a string
rather than a result tree fragment, since that's all you need. I'd
suggest making the same change in your tokenize template.]
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Tokenizing IDREFs, David Carlisle | Thread | [xsl] XSL transformation within an , Bryant, Jeff |
| Re: [xsl] Converting XML source to , Jeni Tennison | Date | [xsl] XSL transformation within an , Bryant, Jeff |
| Month |