|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








