Subject: Re: [xsl] loop problem (NEWBIE) From: Mike Brown <mike@xxxxxxxx> Date: Mon, 9 Sep 2002 12:16:40 -0600 (MDT) |
thomas wrote: > Hello > first a little german-xml for beginners. ;-) > <frage>=<question>, <antwort>=<answer> > got it? ok! > > Im having a problem with the following task. > > > I want a simple fo:table. Left cell, the question, right cell the answer. > I managed to loop over the <frage> and put the content in a new > row/cell. But how do I get the accordant <antwort> in the SAME loop in > the second cell? > > I tried to make 2 loops each and put it in tables next to each other. > The problem is when the content from the right <antwort> table is bigger > than the left <frage> table , the <frage> and <antwort> are not on the > same row. > > > forgive me my ugly source o great xsl programmers. Im a newbie.... > > xml: > <page> > <info> > <profil> > <frage>frage 1 frage 1?</frage> > <antwort>antwort 1 antwort 1 antwort 1 antwort 1</antwort> > <frage>frage 2 frage 2?</frage> > <antwort>antwort 2 antwort 2 antwort 2 antwort 2</antwort> > <frage>frage 3 frage 3?</frage> > <antwort>antwort 3 antwort 3 antwort 3 antwort 3</antwort> > <frage>frage 4 frage 4?</frage> > <antwort>antwort 4 antwort 4 antwort 4 antwort 4</antwort> > </profil> > </info> > </page> The solution will resemble this (HTML tables, but you get the idea): <xsl:template match="profile"> <table> <tbody> <xsl:for-each select="frage"> <tr> <td> <xsl:value-of select="."/> </td> <td> <xsl:value-of select="following-sibling::antwort[1]"/> </td> </tr> </xsl:for-each> </tbody> </table> </xsl:template> Or this (same thing): <xsl:template match="profile"> <table> <tbody> <xsl:apply-templates select="frage"/> </tbody> </table> </xsl:template> <xsl:template match="frage"> <tr> <td> <xsl:value-of select="."/> </td> <td> <xsl:value-of select="following-sibling::antwort[1]"/> </td> </tr> </xsl:template> - Mike ____________________________________________________________________________ mike j. brown | xml/xslt: http://skew.org/xml/ denver/boulder, colorado, usa | resume: http://skew.org/~mike/resume/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] loop problem (NEWBIE), J.Pietschmann | Thread | [xsl] Looking for a book recommenda, Martin Cooper |
Re: [xsl] XSL transform escape ques, Mike Brown | Date | RE: [xsl] XSL transform escape ques, Martinez, Brian |
Month |