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

recursion and looping

Subject: recursion and looping
From: lachance@xxxxxxxxxxxxxxxxx (Francois Lachance)
Date: Thu, 23 Mar 2000 12:08:15 -0500 (EST)
recursion and looping
AIM - group elements according to attribute  value [indeterminate number
of values
Strategy - apply tempates subsequent subsets of nodeset
Problem - how to build the recursion without infinte  loop

Question: is the looping induced by the following stylesheet casued by a
failure to shift context node? If so how can one pass a param value that
cause a shift in context node? Or is this totally wrong-tree barking?

XSLT file

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html"/>

<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>


<xsl:template match="lg">
<xsl:call-template name="grouper" select="//w[@function='item']">
<xsl:with-param name="listname" select="'list1'"/>
</xsl:call-template>
</xsl:template>


<xsl:template name="grouper">

<xsl:param name="listname"/>

<xsl:param name="nodeset" select="//w[@n=$listname]"/>
<xsl:param name="nextset" select="//w[@n!=$listname]a"/>

<xsl:param name="nextlistname" select="$nextset/@n"/>

<xsl:if test="not($nextset='')"> 

<xsl:for-each select="$nodeset">
<xsl:sort select="." order="descending"/>
<xsl:value-of select="."/>
</xsl:for-each>

<xsl:call-template name="grouper">
<xsl:with-param name="listname" select="$nextlistname"/>
</xsl:call-template>

</xsl:if>

</xsl:template>

</xsl:stylesheet>


XML file

<lg>
<l>The <w function="item" n="list1" group="primary">yellow</w> cab drove
away.</l>
<l>The <w function="item" n="list2" group="secondary">green</w> bus slides
to a stop.</l>
<l>The <w function="item" n="list1" group="primary">red</w> truck halted
briefly.<w>nonce</w></l>
<l>The <w function="item" n="list2" group="secondary">purple</w> van sped
away.</l>
</lg>



Desired output: lists of items

yellow red
purple green 

Thanks


-- 
Francois Lachance
Post-doctoral Fellow
projet HYPERLISTES project
http://www.humanities.mcmaster.ca/~hyplist/


 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.