[xsl] Sorting Nested Loops

Subject: [xsl] Sorting Nested Loops
From: "Tyler Queen" <xmllist@xxxxxxxxxxxx>
Date: Tue, 09 Jul 2002 12:53:37 -0700 (PDT)
I appologize for all the spam but I included the wrong
code in the last mailing. Sorry I'm having a off day.
Last try.

I posted this question earlier, but I did'nt include
enough info. I hope this helps. I am having trouble
getting the desired results when I try to sort by an
attribute in a nested loop. I want to sort by the
sequence attribute in ascending order. I get them back
in this order

1, 7, 8, 14, 3, 4, 9, 10, 5, 6, 11, 12, 2, 13

Any ideas?

This is the xml

<?xml version="1.0" encoding="iso-8859-1" ?>
<leadsite>
<tabs>

		<tab typeid="" sequence="1" active="1">
			<label>Tab 1</label>
			<url></url>
		</tab>
		<tab typeid="" sequence="14" active="1">
			<label>Tab 14</label>
			<url></url>
		</tab>

				<tab typeid="" sequence="7" active="1">
			<label>Tab 7</label>
			<url></url>
		</tab>
		<tab typeid="" sequence="8" active="1">
			<label>Tab 8</label>
			<url></url>
		</tab>
				<tab typeid="" sequence="10" active="1">
			<label>Tab 10</label>
			<url></url>
		</tab>
		<tab typeid="" sequence="9" active="1">
			<label>Tab 9</label>
			<url></url>
		</tab>
		<tab typeid="" sequence="3" active="">
			<label>Tab 3</label>
			<url></url>
		</tab>
		<tab typeid="" sequence="4" active="1">
			<label>Tab 4</label>
			<url></url>
		</tab>
				<tab typeid="" sequence="5" active="1">
			<label>Tab 5</label>
			<url>/controlcenter/applications/tyler.asp</url>
		</tab>
		<tab typeid="" sequence="6" active="1">
			<label>Tab 6</label>
			<url></url>
		</tab>
				<tab typeid="" sequence="12" active="1">
			<label>Tab 12</label>
			<url>/controlcenter/applications/tyler.asp</url>
		</tab>
		<tab typeid="" sequence="11" active="1">
			<label>Tab 11</label>
			<url></url>
		</tab>
				<tab typeid="" sequence="13" active="1">
			<label>Tab 13</label>
			<url></url>
		</tab>
		<tab typeid="" sequence="2" active="1">
			<label>Tab 2</label>
			<url></url>
		</tab>
	</tabs>
</leadsite>

This is the xsl


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
	<xsl:template name="tabs" mode="tabs"
match="leadsite/tabs">
	<xsl:for-each select="tab[position() mod 4 = 1]">
		
		<table width="100%" cellpadding="0" cellspacing="0"
border="0">
			<tr>
			<xsl:for-each select=". |
following-sibling::tab[position() &lt; 4]">
			<xsl:sort select="@sequence" data-type="number" />
			<xsl:call-template name="tabcells" />
			</xsl:for-each>
			</tr>
			<![CDATA[</tr>]]>
		</table>
	</xsl:for-each>
	</xsl:template>

	<xsl:template name="tabcells">
		<td valign="Top" align="Left" width="8" class="tabs"
background="images/Agnt_J_Tabrig_Bg.Gif">
			<img height="15" src="images/Agnt_J_Tabrig.Gif"
width="8" />
		</td>
		<td valign="Center" align="Middle" class="tabs"
nowrap="yes">
			<xsl:variable name="url" select="url/." />
			<a href="{$url}">
				<xsl:value-of select="label/." />
			</a>
		</td>
		<td valign="Top" align="Right" width="8" class="tabs"
background="images/Agnt_J_Tablef.Gif">
			<img height="15" src="images/Agnt_J_Tablef.Gif"
width="8" />
		</td>
		<td width="1">
			<img height="1" src="Dot.Gif" width="1" />
		</td>
	</xsl:template>
	
</xsl:stylesheet>


	

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


Current Thread