Subject: XML List -> HTML table
Posted By: JPMRaptor Post Date: 11/14/2003 8:49:34 PM
I'm trying to create a 3 column HTML table from an xml list.  The source XML looks something like:
<root>
 <child id="1"/>
 <child id="2"/>
 ...
</root>

I have a template setup to output the needed info for each child but can't figure out how to generate the proper "tr" tags to break things into rows.

So far my best try looks like:
 <xsl:template match="root">
    <html><body><table>
      <xsl:for-each select="child">
       <hr/>
       <xsl:if test="0 = ((position()-1) mod 2)">
        <tr>
         <xsl:apply-templates select="." />
         <xsl:apply-templates select="following-sibling::child" />
        </tr>
       </xsl:if>
      </xsl:for-each>
    </table></body></html>
 </xsl:template>

What I end up with from this is for each node matching the mod test it runs my child template for all nodes after that.  The following-sibling call is the one causing the multiple calls to the child template.

I'm using the jdk 1.4.2_02 bundled XSLT engine.

Reply By: JPMRaptor Reply Date: 11/14/2003 9:19:03 PM
Never mind, found the solution in the archives:
http://p2p.wrox.com/archive/xslt/2001-05/116.asp


Go to topic 6468

Return to index page 1005
Return to index page 1004
Return to index page 1003
Return to index page 1002
Return to index page 1001
Return to index page 1000
Return to index page 999
Return to index page 998
Return to index page 997
Return to index page 996