This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Tokenizing IDREFs
- To: Stuart Brown <Stuart dot Brown at helicon dot co dot uk>
- Subject: Re: [xsl] Tokenizing IDREFs
- From: Jeni Tennison <jeni at jenitennison dot com>
- Date: Thu, 20 Sep 2001 16:48:12 +0100
- CC: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Organization: Jeni Tennison Consulting Ltd
- References: <6B7D48F33E62D511AE0900B0D0E1BB49020898@erato>
- Reply-To: xsl-list at lists dot mulberrytech dot com
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