p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   XSLT (http://p2p.wrox.com/forumdisplay.php?f=86)
-   -   transform a xml to a html table (http://p2p.wrox.com/showthread.php?t=51047)

robert_trudel_fr December 2nd, 2006 11:00 PM

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

mhkay December 3rd, 2006 03:06 AM

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

robert_trudel_fr December 3rd, 2006 10:46 AM

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


mhkay December 3rd, 2006 02:16 PM

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


All times are GMT -4. The time now is 03:35 AM.

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