[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Tokenizing IDREFs

Subject: Re: Tokenizing IDREFs
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 20 Sep 2001 16:48:12 +0100
Re:  Tokenizing IDREFs
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.