Re: [xsl] two at a time, using a sequence expression

Subject: Re: [xsl] two at a time, using a sequence expression
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Thu, 05 Jun 2008 18:33:26 +0200
John Cavalieri wrote:

  <xsl:template match="/pairs">
    <xsl:copy>
      <xsl:for-each select="for $i in 1 to (count(*) idiv 2 +
(count(*) mod 2)) return *[($i*2)-1]">
        <pair>
          <xsl:copy-of select="." />
          <xsl:copy-of select="./following-sibling::*[1]" />
        </pair>
      </xsl:for-each>
    </xsl:copy>
  </xsl:template>

Doesn't the following suffice to achieve the same result?


  <xsl:template match="/pairs">
    <xsl:copy>
      <xsl:for-each select="*[position() mod 2 = 1]">
        <pair>
          <xsl:copy-of select="."/>
          <xsl:copy-of select="following-sibling::*[1]"/>
        </pair>
      </xsl:for-each>
    </xsl:copy>
  </xsl:template>


--


	Martin Honnen
	http://JavaScript.FAQTs.com/

Current Thread