Subject: RE: [xsl] To simulate SORT inside a xsl:choose condition From: "Dion Houston" <dionh@xxxxxxxxxxxxx> Date: Mon, 29 Apr 2002 15:27:01 -0700 |
Hi Kumar: The way I'd do this is to control the sorting outside of your template... e.g. <People> <Person LastName="Smith" Age="22"/> <Person LastName="Jones" Age="19"/> </People> <xsl:param name="sortMethod">LastName</xsl:param> <xsl:template match="/"> <xsl:choose> <xsl:when test="$sortMethod="LastName"> <xsl:apply-templates select="/People/Person"> <xsl:sort select="@LastName"/> </xsl:apply-templates> </xsl:when> <xsl:when test="$sortMethod="Age"> <xsl:apply-templates select="/People/Person"> <xsl:sort select="@Age"/> </xsl:apply-templates> </xsl:when> </xsl:choose> </xsl:template> In this way, your template can work regardless of the sorting criteria... HTH! Dion -----Original Message----- From: KUMAR NINGASHETTY [mailto:kningashetty@xxxxxxxxxxxxxxxx] Sent: Monday, April 29, 2002 3:15 PM To: < Subject: [xsl] To simulate SORT inside a xsl:choose condition Hi all , I know that the rule to sort should be immediately after <xsl:for-each > I am in a situation where i have to read the criteria to sort from some some node in the beginning of XML and based on which i need to make a decision to sortBY corresponding node somewhere down the line.... But as you know the following way doesnt work ... <xsl:for-each select="somenode"> <xsl:choose> <xsl;when test="$prevnode = 'criteriavalue' "> <xsl:sort order="ascending" select="node_to_be_sorted"/> </xsl:when> </xsl:choose> </xsl:for-each> Note: dont worry about syntax check on this ... Is there a way to sneak around and get this Sorting to work based on some criteria ...Or any other work arounds, suggestions? thanx in advance - kumar 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] To simulate SORT inside a, Michael Kay | Thread | Re: [xsl] To simulate SORT inside a, Joerg Heinicke |
[xsl] To simulate SORT inside a xsl, KUMAR NINGASHETTY | Date | Re: [xsl] javascript in XSLT, Greg Faron |
Month |