xsl-list
[Top] [All Lists]

RE: xsl:for-each result

2005-03-04 10:49:39
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[(_at_)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?

No, it's bound to an empty tree: a document node with no children, whose
effective boolean value is true.

You're using 2.0 here. In 2.0 this kind of thing is done much more easily
using functions. Something like:

<xsl:variable name="title-suffix"
  select="for $x in relation_list/relation[(_at_)class='REP']
          return title-suffix($x)"/>

Michael Kay
http://www.saxonica.com/



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>