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

RE: exit <xsl:for-each> or change <xsl:variable>

Subject: RE: exit <xsl:for-each> or change <xsl:variable>
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Tue, 2 Apr 2002 11:14:32 +0100
xslt exit for each
> Here is the actual problem. If the processor comes across a
> $next-table$
> cell it should:
>
>           <xsl:if test="(cell[1]/data)='$next-table$'">
>             </table><table border="1">
>           </xsl:if>
>
> but that is not possible is it. Is there a way to do this? I
> would like to
> end the current table and start a new one when the value
> '$next-table$'
> shows up.

You're thinking procedurally, and you're thinking in terms of writing tags,
rather than writing nodes.

This is a grouping problem. Use standard grouping techniques
(www.jenitennison.com/xslt/grouping). The grouping key (the property of a
node that determines whether two nodes are in the same group) in your case
is something like:

generate-id(preceding-sibling::cell[data='$next-table'][1])

that is, two nodes are in the same group if they both have the same node as
the most recent $next-table$ cell.

With XSLT 2.0 / Saxon 7.0 you can use pattern-based grouping:

<xsl:for-each-group select="cell"
group-starting-at="cell[data='$next-table']">
  <table>
    <xsl:for-each select="current-group()">
      <tr>
        ....
      </tr>
    </xsl:for-each>
  </table>
</xsl:for-each-group>

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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-2007 All Rights Reserved.