Subject: RE: [xsl] sorting question From: "Oliver Rutherfurd" <fruhstuck@xxxxxxxxxxxxxx> Date: Wed, 7 Mar 2001 08:26:34 -0500 |
Hmm, I see what you mean about efficiency... Well, it's nice to know it can be done, and how to do it ;-). Thanks much for the information. -Ollie > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Diamond, > Jason > Sent: Wednesday, March 07, 2001 8:01 PM > To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx' > Subject: RE: [xsl] sorting question > > > That certainly complicates things. But it is still possible using XSLT > 1.0--although it's certainly not efficient. > > <xsl:transform version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > > > <xsl:output method="xml" encoding="UTF-8" indent="yes"/> > > <xsl:template match="ALPHABET"> > <xsl:for-each select="LETTER"> > <xsl:sort select="."/> > <xsl:if test="position() mod 2 = 1"> > <tr> > <td> > <xsl:value-of select="."/> > </td> > <xsl:variable name="next" select="position() + 1"/> > <xsl:for-each select="../LETTER"> > <xsl:sort select="."/> > <xsl:if test="position() = $next"> > <td> > <xsl:value-of select="."/> > </td> > </xsl:if> > </xsl:for-each> > </tr> > </xsl:if> > </xsl:for-each> > </xsl:template> > > </xsl:transform> > > We're basically iterating over the sorted list and then grabbing the next > element in the sorted list by iterating over the same list > _again_ but only > outputting when we're at the position we want. Would this be O(n*n!)? > > What would be really nice would be a following-node axis (along with a > corresponding preceding-node). This would help select the following or > preceding nodes in the current node list (as constructed by > <xsl:apply-templates> or <xsl:for-each>). This would obviously be specific > to XSLT since XPath doesn't have any notion of a current node > list. This use > case seems like a good justification for those axis specifiers, though. > > Does anybody know if there is anything planned for XSLT 2.0 that > might make > this easier? > > Jason. [snip...] XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] sorting question, Diamond, Jason | Thread | [xsl] Quick XSLT Question, Jaime Carlson |
RE: [xsl] sorting question, Oliver Rutherfurd | Date | Re: [xsl] FXPath v0.3 + SAXON Imple, Jeni Tennison |
Month |