xsl-list
[Top] [All Lists]

Re: [xsl] Problem with count iterate values

2009-09-17 06:58:13
Thank you very much. This is what I mean.
Kind regards,
J23

2009/9/17 David Carlisle <davidc(_at_)nag(_dot_)co(_dot_)uk>:


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>


--~------------------------------------------------------------------
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>
--~--