[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: RE: local extremums

Subject: RE: RE: local extremums
From: cknell@xxxxxxxxxx
Date: Wed, 19 Mar 2003 09:12:33 -0500
select align
> -----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() &lt; 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


Current Thread
  • Re: local extremums, (continued)
      • bix_xslt - Wed, 19 Mar 2003 02:37:44 -0500 (EST)
    • Ragulf Pickaxe - Wed, 19 Mar 2003 03:36:00 -0500 (EST)
    • Ragulf Pickaxe - Wed, 19 Mar 2003 04:27:25 -0500 (EST)
    • cknell - Wed, 19 Mar 2003 09:09:26 -0500 (EST) <=
      • TP - Wed, 19 Mar 2003 09:31:07 -0500 (EST)
        • TP - Wed, 19 Mar 2003 09:54:17 -0500 (EST)
    • David . Pawson - Wed, 19 Mar 2003 09:53:55 -0500 (EST)
      • TP - Wed, 19 Mar 2003 10:19:49 -0500 (EST)

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.