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

Re: Terminate <xsl:for-each>

Subject: Re: Terminate <xsl:for-each>
From: "Joris Gillis" <roac@xxxxxxxxxx>
Date: Sat, 03 Sep 2005 11:57:40 +0200
end xsl for each loop
Tempore 21:30:44, die 09/02/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit aaron apigo <aaronjose_apigo2001@xxxxxxxxx>:

  Using my logic in my sytlesheets, all the
<text:user-field-get> are captured, is there a
possibility that when <for-each> select
<text:bookmark-end text:name="___"/>, <for-each> will
automatically be terminated, and the next
<text:bookmark-start text:name="___"/> will be the one
to process.

No, a 'for-each' loop cannot be terminated in XSLT. You will have to alter your algorithm.


To get some inspiration, you might take a look at this working code snippet:

<xsl:key name="bookmark" match="*"
	use="self::node()
		[preceding::text:bookmark-start[1]/@text:name
		 = following::text:bookmark-end[1]/@text:name]
	/preceding::text:bookmark-start[1]/@text:name"/>

<xsl:template match="text:root">
	<root>
		<xsl:apply-templates select=".//text:bookmark-start"/>
	</root>
</xsl:template>

<xsl:template match="text:bookmark-start">
	<xsl:element name="{@text:name}">
		<xsl:for-each select="key('bookmark',@text:name)[self::text:user-field-get]">
			<tag><xsl:value-of select="."/></tag>
		</xsl:for-each>
	</xsl:element>
</xsl:template>


The 'bookmark' key will return each node, that sits between a 'text:bookmark-start' and a 'text:bookmark-end', by the bookmark's name. It then suffices to filter these nodes with the [self::text:user-field-get] predicate to get only the 'text:user-field-get' elements.


regards,
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
Veni, vidi, wiki (http://www.wikipedia.org)

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.