[xsl] sorting from a set of values

Subject: [xsl] sorting from a set of values
From: "Blaise, Isaac J" <iblaise@xxxxxxxxxxxxx>
Date: Tue, 10 Dec 2002 11:49:55 -0500
hi, 
I'm running a complex sort that I'm trying to translate from a previous SQL sort.  The primary sort is simple, however the secondary sort ((CASE TYPE WHEN 'I' THEN 'I' WHEN 'M' THEN 'I' ELSE 'R' END) desc) is more complicated.  The type can be one of these values: R,U,O,X,M, or I.  

It must sort the nodes in two sets:  1. R,U,O,X    or  2. M and I  based on the value of @i25 in descending order (set 1 would come before set 2).


<611 Identity="80" i0="Y" i1="79"  i25="I" i26="C" i27="0" i29="0" i31="12" i32="$31/M" i33="31" i36="2500" i39="199711" i40="199406" i42="199710" i48="A" i49="8" i50="20" i51="1" i53="N" i54="N" i65="BU" i66="CF"  i69="1" i70="Y" i77="EFX-2" i90="EDU" i91="Y" i92="FZ" i97="N" i98="As Agreed" i64="33"/>

<611 Identity="81" i0="Y" i1="80" i25="I" i26="C" i27="0" i29="0" i31="12" i32="$31/M" i33="31" i36="2500" i39="" i40="199406" i42="199710" i48="A" i49="8" i50="20" i51="1" i53="N" i54="N" i65="BU" i66="CF"  i68="" i70="Y" i77="EFX-2" i90="EDU" i91="Y" i92="FZ" i97="N" i98="As Agreed" i64="33"/>

<611 Identity="91" i0="Y" i1="90"  i25="I" i26="C" i27="139" i29="2102" i31="20" i32="$139/M" i33="139" i36="2500" i39="199906" i40="199709" i42="199812" i48="A" i49="2" i50="9" i51="7" i53="N" i54="Y" i56="199905" i57="-432--422------" i58="3" i59="2" i60="8" i65="DO"  i68="" i69="1" i70="Y" i77="EFX-3" i90="UNS" i91="N" i92="FP" i97="N"  i64="27"/>

<611 Identity="97" i0="Y" i1="96"  i25="I" i26="B" i29="2102" i31="21" i32="24M" i34="24" i36="2500" i39="" i40="" i42="" i48="A" i49="2" i50="9" i51="9" i53="N" i54="Y" i56="199904" i57="" i58="3" i59="2" i60="8" i65="26" i66="69" i68="2563480" i69="3" i72="Y" i79="XPN-1" i90="UNS" i91="Y" i92="FP" i97="N" i64="27"/>

my first thought was to create variables (named R and I), set them to the node values, and sort based on R and then I.  something like this:

			<xsl:variable name="R" select="*|I611[@i25='R' or @i25='U' or @i25='O' or @i25='X']/@i25"/>
			<xsl:variable name="I" select="*|I611[@i25='M' or @i25='I']/@i25"/>

then calling the sorts:
			<xsl:apply-templates select="@* | 611">
				<xsl:sort select="@i54"/>
				<xsl:sort select="R" order="descending"/>
				<xsl:sort select="I" order="descending"/>
				<xsl:sort select="@i29" data-type="number" order="descending"/>
			</xsl:apply-templates>

your thoughts?

thanks,

Isaac
Info1


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


Current Thread