|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: RE: local extremums
> -----Original Message-----
> From: saigo@xxxxxxxxxxxxx (Evgenia Firsova)
> I need to output every Range one by one and mark those who is local
> maxumums (not only one, but every) as bold.
I am going to assume that when you say "output", that you want to transform the XML file to an HTML file. I say this because XML has no concept of "bold" because that is a display property and XML is not about display, but about the data.
Proceeding with that assumption, I have made the stylesheet which appears below which will transform the document sample you posted to HTML. It creates a table with a row for each "Range" element and a column for each attribute of the "Range" element.
The stylesheet sorts the "Range" children of each "Country" element in descending numerical order based on the value of the "Cnt" attribute. I marks as bold the first three rows. These rows contain the highest three values for "Cnt", but there is problem if, as is likely, you could have the same value for several "Cnt" attributes.
If the highest four values for "Cnt" were, for example, 100, 99, 98, 98, the stylesheet would only set bold the first three rows even though the fourth row has a "Cnt" value which is among the highest three values.
Someone else may want to devise a test to handle this situation.
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" indent="yes" encoding="UTF-8" />
<xsl:template match="/">
<html>
<body>
<table>
<colgroup>
<col width="80px" />
<col width="40px" />
<col width="80px" />
<col width="80px" />
<col width="80px" />
</colgroup>
<tr><td></td><td></td><td style="text-align:right;">Price From</td><td style="text-align:right;">Price To</td><td style="text-align:right;">Count</td></tr>
<xsl:apply-templates />
</table>
</body>
</html>
</xsl:template>
<xsl:template match="PoketTourList/Country">
<tr><td>Country ID</td><td><xsl:value-of select="@ID" /></td></tr>
<xsl:for-each select="Range">
<xsl:sort select="@Cnt" data-type="number" order="descending" />
<xsl:choose>
<xsl:when test="position() < 4">
<tr><td></td><td></td><td style="font-weight:bold;text-align:right;"><xsl:value-of select="@PriceFrom" /></td><td style="font-weight:bold;text-align:right;"><xsl:value-of select="@PriceTo" /></td><td style="font-weight:bold;text-align:right;"><xsl:value-of select="@Cnt" /></td></tr>
</xsl:when>
<xsl:otherwise>
<tr><td></td><td></td><td style="text-align:right;"><xsl:value-of select="@PriceFrom" /></td><td style="text-align:right;"><xsl:value-of select="@PriceTo" /></td><td style="text-align:right;"><xsl:value-of select="@Cnt" /></td></tr>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
--
Charles Knell
cknell@xxxxxxxxxx - email
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








