ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> xsl-list
xsl-list
Re: [xsl] even and odds
by =?iso-8859-1?Q?J=F6rg_Heinicke?= other posts by this author
Dec 22 2001 2:29AM messages near this date
Re: [xsl] silbings | Re: [xsl] even and odds
Hi Yan,

an example:

<nodes> 
    <node> 1</node>
    <node> 2</node>
    <node> 3</node>
    <node> 4</node>
    <node> 5</node>
    <node> 6</node>
</nodes> 

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <xsl:template match="/nodes"> 
        <table> 
            <xsl:apply-templates select="node[position() mod 2 = 1]"/> 
        </table> 
    </xsl:template> 

    <xsl:template match="node"> 
        <tr> 
            <td> <xsl:value-of select="."/></td>
            <td> <xsl:value-of select="preceding-sibling::node[1]"/></td>
        </tr> 
    </xsl:template> 
</xsl:stylesheet> 

You match only on every second node, so you know where to close and open
<tr> . And while processing these nodes you select their value and the value
of the next one.

Regards,

Joerg

>  hey all,
>      I have a quick problem.
> 
>      I have n number of nodes, I want to put those nodes as html.
>      I need to take a pair at a time, and display them in a table,
something like:
> 
>      <tr><td>node1</td><td>node2</td></tr>
> 
>      the problem is, when I put <tr> tag in there, I can only
>      put tr in front of the odd ones, and </tr> to the end of the even
ones.
> 
>      Now, I can check even/odd using postion() mode etc, but now it
complains
> 
>      <td> has no end tag, must be due to the conditional statement, how do
I fix
> 
>      this?
> 
>      thanks
> 
>  yan


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
Thread:
Dimitre Novatchev
Yan Zhu
Michael Kay
Yan Zhu
Oleg Tkachenko
Yan Zhu
Michael Kay
Yan Zhu
=?iso-8859-1?Q?J=F6rg_Heinicke?=
Yan Zhu
Gunther Schadow
Dimitre Novatchev
Gunther Schadow
Dimitre Novatchev
Dimitre Novatchev
Gunther Schadow
Yan Zhu

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved