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: count selected nodes in for-each


Hi Kristof:

At 04:23 PM 4/4/01, you wrote:
>xsl:choose is outside the xsl:for-each of course

Why "of course"?

Ahh -- given your example, it seems you want some logic like:

<xsl:for-each select="(...)">
...
</xsl:for-each>
<xsl:if test="(no nodes were handled by for-each)">
</xsl:if>

Then you could just do

<xsl:for-each 
select="document('../../released_xml/news_xml_en/newsticker.xml')/News/Block[@STARTDATE 
= '01']" >...</xsl:for-each>
<xsl:if 
test="not(document('../../released_xml/news_xml_en/newsticker.xml')/News/Block[@STARTDATE 
= '01'])">...</xsl:if>

or, more efficiently and clearer:

<xsl:variable name="blocks" 
select="document('../../released_xml/news_xml_en/newsticker.xml')/News/Block[@STARTDATE 
= '01']"/>
<xsl:for-each select="$blocks" >...</xsl:for-each>
<xsl:if test="not($blocks)">...</xsl:if>

But of course I'm still guessing a bit as to what you're trying to do...:-)

Cheers,
Wendell

>-----Original Message-----
>From: David Carlisle [mailto:davidc@nag.co.uk]
>Sent: woensdag 4 april 2001 17:11
>To: xsl-list@lists.mulberrytech.com
>Subject: Re: [xsl] count selected nodes in for-each
>
>
> > ...
>
>you haven't said whether the xsl:choose is inside or outside the
>for-each.
>
>If it's inside then you can use last() otherwise you can use
>  count(document('../../released_xml/news_xml_en/newsticker.xml')/News/Block
>    [@STARTDATE = '01']" )
>
>David
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

======================================================================
Wendell Piez                            mailto:wapiez@mulberrytech.com
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
   Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


 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]