xsl-list
[Top] [All Lists]

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

2008-06-05 09:33:56
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/

--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>