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

RE: Question on loops

Subject: RE: Question on loops
From: <Jarno.Elovirta@xxxxxxxxx>
Date: Tue, 23 Mar 2004 12:34:06 +0200
select following sibling
Hi,

> <?xml version="1.0" encoding="UTF-8"?>
> <DBInspector ReportName="Query Report" Date="15.01.2004">
> 	<SQLStatement>select * from testdb2.person p, 
> testdb2.adresse a where 
> p.persnr = a.persnr</SQLStatement>
> 	<ColumnNames>
> 		<Column>persnr</Column>
> 		<Column>name</Column>
> 		<Column>vorname</Column>
> 		<Column>nr</Column>
> 		...
> 	</ColumnNames>
> 	<ColumnEntries>
> 		<Row>
> 			<Entrie type="Integer">1</Entrie>
> 			<Entrie type="Variable 
> Character">Wehnert</Entrie>
> 			<Entrie type="Variable 
> Character">Lothar</Entrie>
> 			<Entrie type="Variable Character">Yoyo</Entrie>
> 			<Entrie type="Variable 
> Character">Lothar</Entrie>
> 			...
> 		</Row>
> 		<Row>
> 			<Entrie type="Integer">2</Entrie>
> 			<Entrie type="Variable Character">Egg</Entrie>
> 			<Entrie type="Variable Character">Loth</Entrie>
> 			<Entrie type="Variable Character">Was</Entrie>
> 			<Entrie type="Variable Character">Ertz</Entrie>
> 			...
> 		</Row>
> 		...
> 
> My aim is to create a table after e.g. every second column.
> 
> Something like this:
> 
> persnr   name
> ----------------
> 1        Wehnert
> 2        Egg
> 
> 
> vorname  nr
> ----------------
> Yoyo     Lothar
> Was      Ertz

Do you have an error in your example, because the third Entrie is always ignored and you only have four Columns? Anyhow, the approach still applies. 

  <xsl:template match="ColumnNames">
    <xsl:for-each select="Column[position() mod 2 = 1]">
      <xsl:variable name="position" select="position() * 2 - 1"/>
      <table>
        <thead>
          <tr>
            <th>
              <xsl:value-of select="."/>
            </th>
            <th>
              <xsl:value-of select="following-sibling::Column[1]"/>
            </th>
          </tr>
        </thead>
        <tbody>
          <xsl:value-of select="$position"/>
          <xsl:for-each select="../../ColumnEntries/Row/Entrie[position() = $position]">
            <tr>
              <td>
                <xsl:value-of select="."/>
              </td>
              <td>
                <xsl:value-of select="following-sibling::Entrie[1]"/>
              </td>
            </tr>
          </xsl:for-each>
        </tbody>
      </table>
    </xsl:for-each>
  </xsl:template>

Cheers,

Jarno - neuroticfish: wakemeup! (club-edit)

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.