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

Re: Problem with count iterate values

Subject: Re: Problem with count iterate values
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 17 Sep 2009 11:44:35 +0100
Re:  Problem with count iterate values
> I would like to have output:

are you sure?

> 2 times the same value in file: 2 values

I only see one value repeated twice 11 (13 is repeated twice but you
said not to count rows 	with code=0.


David



$ saxon row.xml row.xsl
<html xmlns:exslt="http://exslt.org/common">
   <body>
      <table border="1" bordercolor="black">
         <thead>
            <tr>
               <th>How many times</th>
            </tr>
         </thead>
         <tbody>
            <tr>
               <td>4</td>
               <td> values repeated 1 times</td>
               <td>(2 44 13 14 )</td>
            </tr>
            <tr>
               <td>1</td>
               <td> values repeated 2 times</td>
               <td>(11 )</td>
            </tr>
            <tr>
               <td>1</td>
               <td> values repeated 3 times</td>
               <td>(1 )</td>
            </tr>
         </tbody>
      </table>
   </body>
</html>





<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
		xmlns:exslt="http://exslt.org/common"
		version="1.0">
 
 <xsl:template match="/" >
  <html>
   <body>
    <xsl:apply-templates />
   </body>
  </html>
 </xsl:template>
 
 <xsl:key name="list" match="Row" use="value" />
 <xsl:key name="value" match="a" use="c" />
 <xsl:template match="elements">	
  <table border="1" bordercolor="black">
   <thead>
    <tr>
     <th>How many times</th>
    </tr>
   </thead>
   <tbody>
    <xsl:variable name="p1">
     <xsl:for-each select="Row[count(. | key('list', value)[1]) = 1]">
      <a>
       <v><xsl:value-of select="value"/></v>
       <c><xsl:value-of select="count(key('list', value)[code != '0'])"/></c>
      </a>
     </xsl:for-each>
    </xsl:variable>
    <xsl:for-each select="exslt:node-set($p1)/a[count(.|key('value',c)[1])=1]">
     <xsl:sort select="c"/>
     <tr>
      <td><xsl:value-of select="count(key('value',c))"/></td>
      <td> values repeated <xsl:value-of select="c"/> times</td>
      <td>(<xsl:for-each select="key('value',c)">
      <xsl:value-of select="v"/>
      <xsl:text> </xsl:text></xsl:for-each>)</td>
     </tr>
    </xsl:for-each>
   </tbody>
  </table>
 </xsl:template>

</xsl:stylesheet>

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________

Current Thread

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.