[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: even and odds

Subject: Re: even and odds
From: Yan Zhu <yan.zhu@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 21 Dec 2001 21:12:30 -0600
xsl node position even odd
I actually independently figure out the same solution,
except I only match on the first one and use following:,
thanks so much!

yan


Jörg Heinicke wrote:

> 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


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.