Subject: Re: [xsl] building a tabular format of data From: "V K" <aad2001@xxxxxxxxx> Date: Wed, 30 Jan 2002 21:40:06 -0800 |
Here's what I came up with -- ************ <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" encoding="Windows-1252"/> <xsl:key name="GetDates" match="testdatetime" use="." /> <xsl:key name="GetElements" match="testname" use="." /> <xsl:template match="/"> <html> <head></head> <body> <table border="1"> <tr> <td><xsl:text> </xsl:text></td> <xsl:for-each select="/reportdetailinfo/testreport/testdatetime[count(. | key('GetDates', .)[1]) = 1]"> <td><xsl:value-of select="." /></td> </xsl:for-each> </tr> <xsl:apply-templates select = "/reportdetailinfo/testreport"> <xsl:sort select="testname" order="ascending"/> </xsl:apply-templates> </table> </body> </html> </xsl:template> <xsl:template match="testreport"> <xsl:for-each select="testname[count(. | key('GetElements', .)[1]) = 1]"> <xsl:apply-templates select = "." /> </xsl:for-each> </xsl:template> <xsl:template match="testname"> <tr> <td><xsl:value-of select="." /></td> <xsl:call-template name="ElementDetails"> <xsl:with-param name="theTestName" select="."/> </xsl:call-template> </tr> </xsl:template> <xsl:template name="ElementDetails"> <xsl:param name="theTestName"/> <xsl:for-each select="/reportdetailinfo/testreport/testdatetime[count(. | key('GetDates', .)[1]) = 1]"> <xsl:variable name = "theTestDateTime" select = "." /> <xsl:choose> <xsl:when test="/reportdetailinfo/testreport[testname=$theTestName and testdatetime=$theTestDateTime]"> <td><xsl:value-of select="/reportdetailinfo/testreport[testname=$theTestName and testdatetime=$theTestDateTime]/testresult" /></td> </xsl:when> <xsl:otherwise> <td><xsl:text> </xsl:text></td> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:template> </xsl:stylesheet> *********** and here's the HTML output <html> <head> <META http-equiv="Content-Type" content="text/html; charset=Windows-1252"> </head> <body> <table border="1"> <tr> <td> </td> <td>12/12/98 10 am</td> <td>12/21/98 12-30 am</td> <td>10/16/97 10 pm</td> </tr> <tr> <td>Potassium</td> <td>33.6</td> <td> </td> <td>10.89</td> </tr> <tr> <td>Saline</td> <td>10.54</td> <td>15</td> <td> </td> </tr> <tr> <td>Sodium</td> <td>16.84</td> <td>11.66</td> <td> </td> </tr> </table> </body> </html> *********** HTH, Atul XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] check if a* not equal to , Bryan Rasmussen | Thread | [xsl] RE: No Subject Line, McNally, David |
[xsl] Java method call error, Khalid Ali | Date | [xsl] asp and xsl, Gene LaCava |
Month |