Re: [xsl] Sorted node set and following-sibling axis

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" 

  <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:template match="articles">
    <xsl:for-each select="$articles/p">
      <xsl:if test="position() mod 2 = 1">
          <xsl:copy-of select="."/>
          <xsl:copy-of select="following-sibling::*[1]"/>


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