This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: building a tabular format of data


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@lists.mulberrytech.com
[mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of Joerg
Heinicke
Sent: Saturday, February 09, 2002 9:48 AM
To: xsl-list@lists.mulberrytech.com
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>&#160;</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>&#160;</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@net-kraft.com]
>
> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]