[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] building a tabular format of data
Subject: RE: [xsl] building a tabular format of data From: "Seema R" <seema.r@xxxxxxxxxxxxx> Date: Wed, 13 Feb 2002 11:14:43 +0530 |
Thanks Joerg, It works just great by itself. However, in the stylesheet that I am using I have already set <xsl:template match="/"> since I have to get values of other nodes before I get to the reportdetailinfo tag. I cannot embed the another <xsl:template> ie; <xsl:template match="reportdetailinfo"> within this. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <html> <body> <form> ...Display some information on patient... ... If the report type is textual display accordingly... Else ... the code as given by you to display tabular format of reports </form> </body> </html> </xsl:template> </xsl:stylesheet> Please let me know if there is some way to solve this. Thanks, Seema. -----Original Message----- From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Joerg Heinicke Sent: Saturday, February 09, 2002 9:48 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] building a tabular format of data I think there was no answer on your problem until now: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes" method="html"/> <!-- grouping by date, without the time --> <!-- adding time-information by replacing all substring(testdatetime,1,8) by testdatetime in the whole file --> <xsl:key name="dates" match="testreport" use="substring(testdatetime,1,8)"/> <xsl:key name="names" match="testreport" use="testname"/> <xsl:template match="reportdetailinfo"> <xsl:variable name="unique_dates" select="testreport[count(.|key('dates', substring(testdatetime,1,8))[1])=1]"/> <table border="1"> <tr> <td> </td> <xsl:for-each select="$unique_dates"> <!-- sort in format yymmdd --> <xsl:sort select="concat(substring(testdatetime,7,2),substring(testdatetime,1,2),subst ring(testdatetime,4,2))"/> <td><xsl:value-of select="substring(testdatetime,1,8)"/></td> </xsl:for-each> </tr> <xsl:apply-templates select="testreport[count(.|key('names', testname)[1])=1]"> <xsl:sort select="testname"/> <xsl:with-param name="unique_dates" select="$unique_dates"/> </xsl:apply-templates> </table> </xsl:template> <xsl:template match="testreport"> <xsl:param name="unique_dates"/> <!-- all testreports with this testname --> <xsl:variable name="names" select="key('names',testname)"/> <tr> <td><xsl:value-of select="testname"/></td> <xsl:for-each select="$unique_dates"> <!-- must be same sort like above --> <xsl:sort select="concat(substring(testdatetime,7,2),substring(testdatetime,1,2),subst ring(testdatetime,4,2))"/> <td> <!-- select the testresult which matches in $names and $dates --> <xsl:value-of select="$names[substring(testdatetime,1,8) = substring(current()/testdatetime,1,8)]/testresult"/> <xsl:text> </xsl:text> </td> </xsl:for-each> </tr> </xsl:template> </xsl:stylesheet> I don't know whether it's the best solution or if it's understandable. I added a few comments, which may help. One thing for more readable XSL-code: change the date-format in XML into a yyyymmdd-format. Regards, Joerg > -----Original Message----- > From: Seema R [mailto:seema.r@xxxxxxxxxxxxx] > > Sorry, I should have known that the tabular format that i had printed it in > would not show as it was done!!! > I will separate the values with asterisks. > Needs to be displayed as ; > ************ 10/16/97***12/12/98***12/21/98 > Potassium **** 10.89 *** 33.6 *** > Saline **** *** 10.54 *** 15 > Sodium **** *** 16.84 *** 11.6 > The output I am getting is: > ************ 10/16/97***12/12/98***12/21/98 > Potassium **** 10.89 *** 33.6 *** > Saline **** 10.54 *** 15 *** > Sodium **** 16.84 *** 11.6 *** > I guess I will have to simply alter the XML structure.................the > problem is that the broker sends it in that format. > Any suggestions other than changing the XML structure? That would be the > last bet. > Thanx, > Seema. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] building a tabular format, Joerg Heinicke | Thread | Re: [xsl] building a tabular format, Joerg Heinicke |
RE: [xsl] (consistency in select re, Edward . Middleton | Date | [xsl] white space to + in query str, bbrosenstock |
Month |
Keywords