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

RE: alternating node type in a loop

Subject: RE: alternating node type in a loop
From: "McNally, David" <David.McNally@xxxxxxxxxx>
Date: Fri, 12 Jul 2002 16:24:02 -0400
alternating nodes
If I understand you correctly, this should do it:

<xsl:apply-templates select="article">
<xsl:sort
select="concat(count(preceding-sibling::article[@type=current()/@type]),'::'
,@type)"/>
</xsl:apply-templates>

which will process the first article of type 1, then the first of type 2
(and potentially the first of type 3), then move on to the second of each
type, etc.

Note that an old version of MSXML that is in my copy of XMLSpy didn't
process this correctly, but Saxon 6.5.2 did.

Hope this helps,
David.
--
David McNally            Moody's Investors Service
Software Engineer        99 Church St, NY NY 10007 
David.McNally@xxxxxxxxxx            (212) 553-7475 


> -----Original Message-----
> From: Tyler Queen [mailto:xmllist@xxxxxxxxxxxx]
> Sent: Friday, July 12, 2002 3:21 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  alternating node type in a loop
> 
> 
> I want to loop through all the article nodes within a
> section element. The problem is I want to alternate the
> way they are looped by "type" going "1,2,1,2,1,2" and
> then when there aren't anymore to alternate through
> finish looping through the remaining nodes.
> Any Ideas?
> 
> This is the xml
> 
> <articles>
> 	<section>
> 		<article type="1">Article</article>
> 		<article type="2">Article</article>
> 		<article type="2">Article</article>
> 		<article type="1">Article</article>
> 		<article type="2">Article</article>
> 		<article type="1">Article</article>
> 		<article type="1">Article</article>
> 		<article type="1">Article</article>
> 	</section>
> <articles>
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


---------------------------------------

The information contained in this e-mail message, and any attachment thereto, is confidential and may not be disclosed without our express permission.  If you are not the intended recipient or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that you have received this message in error and that any review, dissemination, distribution or copying of this message, or any attachment thereto, in whole or in part, is strictly prohibited.  If you have received this message in error, please immediately notify us by telephone, fax or e-mail and delete the message and all of its attachments.  Thank you.

Every effort is made to keep our network free from viruses.  You should, however, review this e-mail message, as well as any attachment thereto, for viruses.  We take no responsibility and have no liability for any computer virus which may be transferred via this e-mail message.


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