xsl-list
[Top] [All Lists]

Re: Problem with count and predicates

2005-06-03 20:00:26
Hey Kent,

In 1.0 or 2.0, as long as I understand what you are looking for the
following will give you want you want:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
<xsl:template match="/">
  <xsl:apply-templates select="stats/month"/>
</xsl:template>
<xsl:template match="month">
  Month: <xsl:value-of select="@name"/>
  Days[&gt; 2]: <xsl:value-of select="count(days[. > 2])"/>
</xsl:template>
</xsl:stylesheet>

Will output:

Month: 6
  Days[&gt; 2]: 3
  Month: 7
  Days[&gt; 2]: 3

using the sample you gave....

Is this what you want?

On 6/3/05, Kent Seegmiller <hookjaw20(_at_)comcast(_dot_)net> wrote:
My brain must be on drugs.  I have a source doc of:

<stats>
 <month name="6" count="4842">
 <days>0</days>
 <days>0</days>
 <days>0</days>
 <days>1</days>
 <days>6</days>
 <days>-16</days>
 <days>3</days>
 <days>2</days>
 <days>3</days>
 <days>1</days>
...
</month>
 <month name="7" count="4537">
 <days>0</days>
 <days>4</days>
 <days>9</days>
 <days>1</days>
 <days>2</days>
 <days>0</days>
 <days>2</days>
 <days>0</days>
 <days>10</days>
 <days>1</days>
...
</month>
...
</stats>
I want to get the count of days that are > 2 for each month and have racked
my brain.  I think the chemo has kicked in.  Please tell me how this is
posible using 2.0

KS



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




-- 
<M:D/>

M. David Peterson
http://www.xsltblog.com

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



<Prev in Thread] Current Thread [Next in Thread>