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

RE: xsl:for-each result

Subject: RE: xsl:for-each result
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 4 Mar 2005 17:49:39 -0000
xsl foreach variable
> 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?

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[@class='REP']
          return title-suffix($x)"/>

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

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.