|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Sorted node set and following-sibling axis
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)
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








