Search the Community
Showing results for tags 'xsl:sort'.
Hi everybody, First post here, hoping someone can help. I'm looking for a way to specify a primary and secondary column to sort by in a table. For example, a list of people that are to be contacted in an emergency, some of whom are "Primary" contacts, and some who are "Alternate" contacts. What I want is for the primaries to be listed first, in alphabetical order, before any alternates, who are also listed alphabetically. (Primary and Alternate have also been assigned a numerical value, with Primary being 1 and Alternate being 2.) Currently, these table sort only on one node, the person's name, so I get: Type Name1. Primary Ben Smith2. Alternate David Willis2. Alternate Mary Jones1. Primary Robert Crane What I want is: Type Name1. Primary Ben Smith1. Primary Robert Crane2. Alternate David Willis2. Alternate Mary Jones The values are being pulled from database software where each field (i.e. "Type" or "Name") has a Field ID that the XSLT uses to populate the output document. Code looks like this right now: <table> <tbody> <tr> <th>Type</th> <th>Name</th> </tr> <xsl:for-each select="Record/Field[ID='8132']"> <xsl:sort select="../Field[ID='8131']/Value"/> <tr> <td><xsl:value-of select="../Field[ID='8132']/Value"/></td> <td><xsl:value-of select="../Field[ID='8131']/Value"/></td> </xsl:for-each> </tr> </tbody></table> '8132' is the Type field, '8131' is the Name field. Hope I've explained this clearly. Thanks in advance for any assistance!