xsl-list
[Top] [All Lists]

Re: loop problem (NEWBIE)

2002-09-09 10:58:05
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



<Prev in Thread] Current Thread [Next in Thread>