Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 14th, 2003, 09:49 PM
Registered User
 
Join Date: Nov 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default XML List -> HTML table

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">

       <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 With Quote
  #2 (permalink)  
Old November 14th, 2003, 10:19 PM
Registered User
 
Join Date: Nov 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Never mind, found the solution in the archives:
http://p2p.wrox.com/archive/xslt/2001-05/116.asp

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
transform a xml to a html table robert_trudel_fr XSLT 3 December 3rd, 2006 02:16 PM
How to insert <br> in a table with this xml/xsl? andigra XSLT 1 September 22nd, 2006 07:01 AM
Achitecture ? SQL -> XML -> ASP -> PDF or HTML Frm jstrong Classic ASP XML 0 July 9th, 2005 01:18 PM
XML to HTML Table with Sorting and Distinct VictorMk XSLT 4 April 23rd, 2004 06:29 PM
putting xml data in a html <table> rev XSLT 4 September 10th, 2003 08:49 AM



All times are GMT -4. The time now is 09:44 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.