xsl-list
[Top] [All Lists]

[xsl] Adding the results of count()

2010-11-22 13:05:48

I could use some help taking the results of counting all of the elements in set 
of documents, then adding all those counts together.

What I've written, of course, creates a text documents that lists the source 
document and how many graphic elements are in each particular document. My 
question, how can I take the results of the count and add them up using the 
sum() function. Or can I even do that?

Of course, I can always open the result document and add them up with a 
calculator, but I'd like to be a bit more elegant and learn something in the 
process. Thanks for any assistance.



    <xsl:param name="collection" 
select="collection('file:/C:/documents/?select=*.xml')"/>
    
    <xsl:template match="/">
        <xsl:result-document method="text" 
href="file:/C:/results/graphic_Count.txt">
        <xsl:for-each select="$collection">
            <xsl:value-of select="base-uri(.)"/><xsl:text>  ---   </xsl:text>
                <xsl:value-of select="local-name()"/>
                <xsl:value-of select="count(descendant::graphic)"/>
            <xsl:text>&#x0A;</xsl:text>
        </xsl:for-each>
    </xsl:result-document>
  
    </xsl:template>



Charlie

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