[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] xsl:for-each result


Subject: [xsl] xsl:for-each result
From: Kevin Rodgers <kevin.rodgers@xxxxxxx>
Date: Fri, 4 Mar 2005 10:31:16 -0700

I'm binding the result of for-each to a variable like this:

    <xsl:variable name="title-suffix">
      <xsl:for-each select="relation_list/relation[@class='REP']">
        <xsl:call-template name="title-suffix">
          <xsl:with-param name="relation" select="."/>
        </xsl:call-template>
      </xsl:for-each>
    </xsl:variable>

My problem arises when no nodes match the select expression and so the
title-suffix template isn't called.  Shouldn't the title-suffix variable
be bound to an empty sequence, whose effective boolean value is false?

I try to detect that situation in this instruction:

    <xsl:call-template name="data-element">
      <xsl:with-param name="code" select="'TL'"/>
      <xsl:with-param name="value"
         select="if ($title-suffix)
                 then substring(concat($title, ' ', $title-suffix), 1, 304)
                 else $title"/>
    </xsl:call-template>

But my tests indicate that the title-suffix variable is a seqence of 1
node, an empty text node I think.  What is the explanation for that, and
how should I test for the empty suffix?

Thanks,
-- 
Kevin Rodgers


Current Thread