This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Displaying every 2 element values in 1 rowy
- To: xsl-list at mulberrytech dot com
- Subject: Re: Displaying every 2 element values in 1 rowy
- From: Mike Brown <mike at skew dot org>
- Date: Tue, 25 Apr 2000 19:27:49 -0600 (MDT)
- Reply-To: xsl-list at mulberrytech dot com
> How can I display every two element node values in one row by checking the
> position?
>
> If I have an xml like:
>
> <eno>A21</eno>
> <eno>A22</eno>
> <eno>A23</eno>
> <eno>A24</eno>
> <eno>A25</eno>
> <eno>A26</eno>
<!-- look at every 1st, 3rd, 5th, etc 'eno' element child of current node -->
<xsl:for-each select="eno[position() mod 2 = 1]">
<!-- start a new table row -->
<tr>
<!-- cell 1: value of current 'eno' -->
<td>
<xsl:value-of select="."/>
</td>
<!-- cell 2: value of next 'eno' or a non-breaking space if none -->
<td>
<xsl:choose>
<xsl:when test="following-sibling::eno">
<xsl:value-of select="following-sibling::eno"/>
</xsl:when>
<xsl:otherwise> </xsl:otherwise>
</td>
</tr>
</xsl:for-each>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list