This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Displaying every 2 element values in 1 rowy


> 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>&#160;</xsl:otherwise>
    </td>
  </tr>
</xsl:for-each>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]