This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: loop problem (NEWBIE)
- From: "J.Pietschmann" <j3322ptm at yahoo dot de>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Mon, 09 Sep 2002 19:58:05 +0200
- Subject: Re: [xsl] loop problem (NEWBIE)
- References: <3D7CD867.9090507@ksc.ch>
- Reply-to: xsl-list at lists dot mulberrytech dot com
thomas wrote:
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?
Your XML is not well designed for this. The standard technique is
to use pairs of frage+antwort.
<profil>
<f-a>
<frage>frage 1 frage 1?</frage>
<antwort>antwort 1 antwort 1 antwort 1 antwort 1</antwort>
</f-a>
...
BTW XSLT does not loop. Do not confuse xsl:for-each with for example
a Java for(x;y;z). It is more comparable to a SQL SELECT.
If you are stuck with your XML, and you are sure the answer to
a certain question is always the antwort element after the frage
element, you can select the questions and get the according answer
using the following-sibling axis:
...
<fo:table-body>
<xsl:for-each select="/page/info/profil/frage">
<fo:table-row>
<fo:table-cell>
<fo:block>
<xsl:value-of select="."/>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:value-of select="following-sibling::aantowrt[1]"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
...
J.Pietschmann
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list