Subject: Re: [xsl] Problem with count iterate values From: J23 <duniaj@xxxxxxxxxxxx> Date: Sat, 19 Sep 2009 17:59:40 +0200 |
Hello, Now I try make following similar table: Name |Values repeated 1 times | Values repeated 2 times | Values repeated 3 times |....... ----------------------------------------------------------------------------- ------------- Mark | (HowManyTimes) | (HowManyTimes) | (HowManyTimes) |....... ----------------------------------------------------------------------------- ------------- Peter| (HowManyTimes) | (HowManyTimes) | (HowManyTimes) |....... ----------------------------------------------------------------------------- ------------- Paul | (HowManyTimes) | (HowManyTimes) | (HowManyTimes) |....... ----------------------------------------------------------------------------- ------------- .... | ... | ... | ... |....... ----------------------------------------------------------------------------- ------------- It is possible to do? I add this: <xsl:key name="Name" match="elements/Row" use="name" /> <xsl:for-each select="Row[count(. | key('Name', name)[1]) = 1]"> <tr> <td><xsl:value-of select="name" /></td> <td><xsl:value-of select="count(key('list', value)[code != '0'])" /></td> </tr> </xsl:for-each> My problem is now that I don't know how to coalesce count by name with previous code, and how I can make this dynamic columns. xml input: <?xml version="1.0"?> <?xml-stylesheet href="xsl.xsl" type="text/xsl" ?> <elements> <Row Nr="1"> <name>Mark</name> <value>1</value> <code>22</code> </Row> <Row Nr="2"> <name>Mark</name> <value>1</value> <code>1</code> </Row> <Row Nr="3"> <name>Paul</name> <value>2</value> <code>2</code> </Row> <Row Nr="4"> <name>Mark</name> <value>1</value> <code>2</code> </Row> <Row Nr="5"> <name>Peter</name> <value>44</value> <code>2</code> </Row> <Row Nr="6"> <name>Peter</name> <value>1</value> <code>0</code> </Row> <Row Nr="7"> <name>Paul</name> <value>11</value> <code>1</code> </Row> <Row Nr="8"> <name>Peter</name> <value>11</value> <code>1</code> </Row> <Row Nr="9"> <name>Mark</name> <value>13</value> <code>0</code> </Row> <Row Nr="10"> <name>Peter</name> <value>13</value> <code>1</code> </Row> <Row Nr="11"> <name>Paul</name> <value>14</value> <code>1</code> </Row> </elements> Please give me advice. Kind regards, J23 2009/9/17 David Carlisle <davidc@xxxxxxxxx>: > > >> 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. > ________________________________________________________________________ > > -- Pozdrawiam Jacek Dunia
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Problem with count iterat, J23 | Thread | Re: [xsl] Problem with count iterat, Martin Honnen |
RE: [xsl] Creating multiple nodes f, Michael Kay | Date | Re: [xsl] Problem with count iterat, Martin Honnen |
Month |