This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]