Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 2nd, 2006, 11:00 PM
Registered User
 
Join Date: Dec 2006
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
 
Old December 3rd, 2006, 03:06 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 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
 
Old December 3rd, 2006, 10:46 AM
Registered User
 
Join Date: Dec 2006
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

 
Old December 3rd, 2006, 02:16 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 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





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.