Hi,
I am learning XSL and have been struggling with the same question for a
couple of days. It is probably a simple question to someone familiar with
XSL so I was hoping to get some help. Below are portions of my XSL and
XML files. Basically, for each different base (ELS, LAN, KAD) I want to
display only one record in a html page, the one record is the one with the
highest CREATIONTIME value. I have tried many methods and none of them
has worked. Below is the latest and almost successful method. It sorts
the list in the way I want. and then in <template match="Report"> I try
to remove the duplicates so only the first base from the sorted list is
displayed. The problem is that I am not able to apply the preceding node
to the sorted list created in the XSL file, the XSL just applies the
preceding node test to the XML file. How can I sort the XML file and the
apply the preceding node test to the sorted list? Or is there a better
method altogether? Any help would be greatly appreciated.
Thanks, Nicole
<xsl:template match="/">
<html>
<body>
<table border="1" cellspacing="1" cellpadding="1"
align="center">
<tr class="formtitle" align="center">
<td>Base Status</td>
<td>Creation Time</td>
<td>ASC</td>
</tr>
<xsl:apply-templates select="//Document/Report">
<xsl:sort order='ascending'
select='@base'/>
<xsl:sort order='descending'
select='../@CREATIONTIME'/>
</xsl:apply-templates>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="Report">
<xsl:if test="not ((preceding::*[1]/@base)=(_at_)base) ">
<xsl:call-template name="print"/>
</xsl:if>
</xsl:template>
<xsl:template name="print">
<tr class="formtext">
<td class="formtitle">print <xsl:value-of
select='@base'/></td>
<td><xsl:value-of select='../@CREATIONTIME'/></td>
</tr>
<tr class="formtext">
<td class="formtitle" align="right">Authorized</td>
<td align="center"><xsl:value-of
select="Authorized/@ASC"/></td>
</tr>
</xsl:template>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Sample XML data
<?xml-stylesheet href="SparesCalc.xsl" type="text/xsl" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<docs>
<Document CREATIONTIME="200605040811">
<Report ID="759b" base="ELS">
<Authorized ASC="2"/>
</Report>
</Document>
<Document CREATIONTIME="20060404115819">
<Report ID="759a" base="LAN">
<Authorized ASC="0"/>
</Report>
</Document>
<Document CREATIONTIME="200605041506">
<Report ID="759c" base="LAN">
<Authorized ASC="0"/>
</Report>
</Document>
<Document CREATIONTIME="200605041507">
<Report ID="759d" base="ELS">
<Authorized ASC="2"/>
</Report>
</Document>
<Document CREATIONTIME="20060503111352">
<Report ID="759e" base="KAD">
<Authorized ASC="4"/>
</Report>
</Document>
</docs>
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--