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)
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--