This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: even and odds
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