Subject: Re: [xsl] Sorted node set and following-sibling axis From: JBryant@xxxxxxxxx Date: Wed, 10 Aug 2005 13:51:27 -0500 |
A slight improvement - the test for a following sibling is unnecessary, as the processor will just do nothing if it can't find a following sibling. Thus, the following stylesheet does just as well: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:variable name="articles"> <xsl:for-each select="/articles/article"> <xsl:sort select="@priority" data-type="number" order="descending"/> <p><xsl:value-of select="."/></p> </xsl:for-each> </xsl:variable> <xsl:template match="articles"> <xsl:for-each select="$articles/p"> <xsl:if test="position() mod 2 = 1"> <div> <xsl:copy-of select="."/> <xsl:copy-of select="following-sibling::*[1]"/> </div> </xsl:if> </xsl:for-each> </xsl:template> </xsl:stylesheet> I usually just want something that works as a first step, and then I work on optimization (usually for maintainability rather than performance). This stylesheet is a case in point, I guess. Jay Bryant Bryant Communication Services (presently consulting at Syngeristic Solution Technologies)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Sorted node set and follo, JBryant | Thread | Re: [xsl] Sorted node set and follo, Nick Fitzsimons |
Re: [xsl] Sorted node set and follo, JBryant | Date | Re: [xsl] Joining sibling elements, Joris Gillis |
Month |