RockDad Posted January 28, 2010 Share Posted January 28, 2010 The example shown is a little different in the way that my xml file is configured, however I have no idea on how to configure the XSLT file to display the data within my xml file. Here is a sample of my xml file:<chart caption="TestChart" yAxisName="Median" bgColor="F7F7F7, E9E9E9" showValues="0" numVDivLines="10" divLineAlpha="25" labelPadding="5" yAxisValuesPadding="5"><categories><category label= "11/2009" /><category label= "12/2009" /><category label= "1/2010" /></categories><dataset seriesname= "Type1"><set value= "139" /><set value= "208" /><set value= "167" /></dataset><dataset seriesname= "Type2"><set value= "167" /><set value= "113" /><set value= "186" /></dataset></chart>I need to display this data like so:Type | 11/2009 | 12/2009 | 1/2010Type1 | 139 | 208 | 167Type2 | 167 | 113 | 186Any ideas to get me started would be appreciated, thanks in advance! Link to comment Share on other sites More sharing options...
boen_robot Posted January 29, 2010 Share Posted January 29, 2010 Do you want to display it as a table, or as plain text (exactly as shown)? I'll assume you mean a table. <?xml version="1.0"?><xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/chart"> <html> <body> <table> <thead> <xsl:for-each select="categories"> <tr> <xsl:for-each select="category"> <th><xsl:value-of select="@label" /></th> </xsl:for-each> </tr> </xsl:for-each> </thead> <tbody> <xsl:for-each select="dataset"> <tr> <th><xsl:value-of select="@seriesname" /></th> <xsl:for-each select="set"> <td><xsl:value-of select="@value" /></td> </xsl:for-each> </tr> </xsl:for-each> </tbody> </table> </body> </html></xsl:template></xsl:stylesheet> Link to comment Share on other sites More sharing options...
RockDad Posted January 29, 2010 Author Share Posted January 29, 2010 Do you want to display it as a table, or as plain text (exactly as shown)? I'll assume you mean a table.<?xml version="1.0"?><xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/chart"> <html> <body> <table> <thead> <xsl:for-each select="categories"> <tr> <xsl:for-each select="category"> <th><xsl:value-of select="@label" /></th> </xsl:for-each> </tr> </xsl:for-each> </thead> <tbody> <xsl:for-each select="dataset"> <tr> <th><xsl:value-of select="@seriesname" /></th> <xsl:for-each select="set"> <td><xsl:value-of select="@value" /></td> </xsl:for-each> </tr> </xsl:for-each> </tbody> </table> </body> </html></xsl:template></xsl:stylesheet> Yes, a table is correct.Thanks, this is way AWESOME and more than I expected. But at least I can try and figure out what's going on here. Thanks again, one more question.OK, this may be a dumb question but where are the <td> (columns)? I need a columns before the category label starts and I am not familier with the <thead> and <th> tags. Any ideas? Link to comment Share on other sites More sharing options...
RockDad Posted January 29, 2010 Author Share Posted January 29, 2010 Ahhhh, nevermind, I figured it out based on what you gave me. Thanks again! Link to comment Share on other sites More sharing options...
RockDad Posted January 29, 2010 Author Share Posted January 29, 2010 Do you want to display it as a table, or as plain text (exactly as shown)? I'll assume you mean a table.<?xml version="1.0"?><xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/chart"> <html> <body> <table> <thead> <xsl:for-each select="categories"> <tr> <xsl:for-each select="category"> <th><xsl:value-of select="@label" /></th> </xsl:for-each> </tr> </xsl:for-each> </thead> <tbody> <xsl:for-each select="dataset"> <tr> <th><xsl:value-of select="@seriesname" /></th> <xsl:for-each select="set"> <td><xsl:value-of select="@value" /></td> </xsl:for-each> </tr> </xsl:for-each> </tbody> </table> </body> </html></xsl:template></xsl:stylesheet> OK, I thought I was done. How do I add style elemnts to them for a css? Link to comment Share on other sites More sharing options...
boen_robot Posted January 29, 2010 Share Posted January 29, 2010 What XSLT does is to generate XHTML based on the XML.Having said that, how do you do it in XHTML? I'll let you try to figure that one out yourself (for exercise's sake). Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.