Re: [xsl] Problem with count iterate values

Subject: Re: [xsl] Problem with count iterate values
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 17 Sep 2009 11:44:35 +0100
> 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