Subject: RE: [xsl] Nested xsl:sort problems From: "Josh Canfield" <josh.canfield@xxxxxxxxxxxx> Date: Mon, 8 Dec 2003 17:54:53 -0800 |
I believe the problem was that you were off by one level when doing your sorts. Here is a cut down version of the XSL... <!-- Sorted primary elements --> <xsl:for-each select="/indices/index/entry/primary"> <xsl:sort data-type="text" select="@name"/> <block><xsl:value-of select="@name"/></block> <!-- Sorted secondary elements --> <xsl:for-each select="secondary"> <xsl:sort data-type="text" select="@name"/> <block><xsl:value-of select="@name"/></block> <!-- Sorted tertiary elements --> <xsl:for-each select="tertiary"> <xsl:sort data-type="text" select="@name"/> <block><xsl:value-of select="@name"/></block> </xsl:for-each> </xsl:for-each> </xsl:for-each> This is repetitive, and could probably be replaced with something recursive... Does this solve your problem? Josh -----Original Message----- From: Fred Wells [mailto:Fred.Wells@xxxxxxxxxxxxxxxx] Sent: Monday, December 08, 2003 3:53 PM To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx Subject: [xsl] Nested xsl:sort problems I having a problem with sorting I need to sort down three levels but for some reason I can only get the first level tto sort following is the xml and the xsl respectively: <?xml version="1.0" standalone="yes"?> <indices> <index bookId="ISBN_chapterX"> <entry> <primary name="art history" relPages="191,192,193,194"> <secondary name="artists"> <tertiary name="picasso, pablo" relPages="250"/> <tertiary name="pollock, jackson" relPages="261"/> </secondary> <secondary name="architecture"> <tertiary name="wright, frank lloyd" relPages="262"/> </secondary> </primary> </entry> <entry> <primary name="awards"> <secondary name="television" relPages="171,172"> <tertiary name="emmy" relPages="180"/> <tertiary name="golden globe" relPages="189,211"/> <tertiary name="screen actors guild" relPages="11"/> </secondary> <secondary name="music"> <tertiary name="grammy" relPages="134"/> <tertiary name="mtv video music" relPages="135,180"/> </secondary> <secondary name="theater" relPages="15,16,210"> <tertiary name="tony" relPages="189"/> </secondary> </primary> </entry> <entry> <primary name="newspapers" relPages="1,3,4,90"> <secondary name="new york" relPages="91,92,95"> <tertiary name="village voice" relPages="115"/> <tertiary name="wall street journal" relPages="116,117"/> <tertiary name="new york post" relPages="118,119,120"/> <tertiary name="new york times" relPages="121,122,123,124,125"/> </secondary> <secondary name="chicago" relPages="17,18,19,20"> <tertiary name="chicago tribune" relPages="17"/> <tertiary name="chicago sun times" relPages="18,19,20"/> </secondary> </primary> </entry> <entry> <primary name="games" relPages="21"> <secondary name="chess" relPages="67"/> <secondary name="checkers" relPages="68"/> <secondary name="backgammon" relPages="71,72"/> </primary> </entry> </index> </indices> and the xsl: <xsl:for-each select="//index/entry"> <xsl:sort data-type="text" select="./primary/@name"/> <xsl:for-each select="./primary"> <xsl:sort data-type="text" select="./secondary/@name"/> <fo:block font-family="Helvetica,Arial" font-size="7pt" font-weight="bold" text-align="left"> <xsl:value-of select="@name"/> <xsl:if test=" @relPages != '' "> <xsl:text>

</xsl:text> <xsl:value-of select="@relPages"/> </xsl:if> </fo:block> <xsl:for-each select="./secondary"> <xsl:sort data-type="text" select="./tertiary/@name"/> <fo:block font-family="Helvetica,Arial" font-size="7pt" start-indent="5pt" text-align="left"> <xsl:value-of select="@name"/> <xsl:if test=" @relPages != '' "> <xsl:text>

</xsl:text> <xsl:value-of select="@relPages"/> </xsl:if> </fo:block> <xsl:for-each select="./tertiary"> <fo:block font-family="Helvetica,Arial" font-size="7pt" font-style="italic" start-indent="10pt" text-align="left"> <xsl:value-of select="@name"/> <xsl:if test=" @relPages != '' "> <xsl:text>

</xsl:text> <xsl:value-of select="@relPages"/> </xsl:if> </fo:block> </xsl:for-each> </xsl:for-each> </xsl:for-each> </xsl:for-each> This seems only to work for the 'primary' element and not the 'secondary' and 'tertiary'. I'm pretty new to this so any advice is greatly appreciated. thanks -fw Frederick Wells Capps Digital 35 W Wacker 30th Fl. Chicago, IL 312.220.3056 www.cappsdigital.com XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Nested xsl:sort problems, Todd Baker | Thread | RE: [xsl] Nested xsl:sort problems, Fred Wells |
RE: [xsl] Nested xsl:sort problems, Todd Baker | Date | [xsl] Unbounded element grouping/co, Gupta, Raman K [CI] |
Month |