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 December 2nd, 2006, 11:00 PM
Registered User
 
Join Date: Dec 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default transform a xml to a html table

hi

i search a way to generate a html table with my xml file

i readed some article about xsl but i don't find any way to generate the web page i want from my xml file...

my xml file

Code:
<root>
* <month>
* * <aa>0</aa>
* * <bb>0</bb>
* * <cc>0</cc>
* </month>
* <month>
* * <aa>1</aa>
* * <bb>1</bb>
* * <cc>1</cc>
* </month>
</root>

i would like to generate an html table with these values
Code:
aa  0 1
bb  0 1
cc  0 1
any tips about the xsl to create to be able to generate the html table i want?

thanks
Reply With Quote
  #2 (permalink)  
Old December 3rd, 2006, 03:06 AM
mhkay's Avatar
Wrox Author
Points: 18,438, Level: 59
Points: 18,438, Level: 59 Points: 18,438, Level: 59 Points: 18,438, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,954
Thanks: 0
Thanked 290 Times in 285 Posts
Default

If each of the months has the same internal structure, do something like this:

<xsl:variable name="months" select="month">
<xsl:for-each select="$months[1]/*">
  <xsl:variable name="p" select="position()"/>
  <tr>
    <td><xsl:value-of select="name()"/></td>
    <xsl:for-each select="$months">
      <td><xsl:value-of select="*[$p]"/></td>



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #3 (permalink)  
Old December 3rd, 2006, 10:46 AM
Registered User
 
Join Date: Dec 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by mhkay
 If each of the months has the same internal structure, do something like this:

<xsl:variable name="months" select="month">
<xsl:for-each select="$months[1]/*">
<xsl:variable name="p" select="position()"/>
<tr>
    <td><xsl:value-of select="name()"/></td>
    <xsl:for-each select="$months">
     <td><xsl:value-of select="*[$p]"/></td>



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
surely an error, that display nothing

Reply With Quote
  #4 (permalink)  
Old December 3rd, 2006, 02:16 PM
mhkay's Avatar
Wrox Author
Points: 18,438, Level: 59
Points: 18,438, Level: 59 Points: 18,438, Level: 59 Points: 18,438, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,954
Thanks: 0
Thanked 290 Times in 285 Posts
Default

Well, I only posted an outline. If you complete it wrongly, or use it in the wrong context, then it won't work. You asked for tips, not for working code.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
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 html table to add ids/headers using xsl kapy_kal XSLT 2 February 21st, 2007 10:12 AM
constructing a HTML table from xml data using xslt rameshnarayan XSLT 0 September 19th, 2005 06:53 AM
XML to HTML Table with Sorting and Distinct VictorMk XSLT 4 April 23rd, 2004 06:29 PM
XML List -> HTML table JPMRaptor XSLT 1 November 14th, 2003 10:19 PM



All times are GMT -4. The time now is 05:53 PM.


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