|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








