xsl-list
[Top] [All Lists]

RE: reccursive sum ?

2004-03-03 05:55:40
Thanks David, i think i see the things better now.
I'm trying to use the whole node set of my xml files to count the DEVOIRS
but i still have a little problem using
select="count(document(saxon:node-set($addxml)/ME/@id)/ME/FOURN/DEVOIR"/>

My xslt processor is MSXML, the node-set function is msxsl:node-set (I added
xmlns:msxsl="urn:schemas-microsoft-com:xslt" in the namespace declaration)
One more thing is that my xml files are not in the same folder, i need to go
"../ME/".

This is what i wrote :

<xsl:call-template name="SUM">
        <xsl:with-param name="addxml">
                <xsl:for-each select="ME">
                        <ME>
                        <xsl:attribute name="id">../ME/<xsl:value-of
select="@id"/>.xml</xsl:attribute>
                        </ME>
                </xsl:for-each>
        </xsl:with-param>
</xsl:call-template>

<xsl:value-of
select="count(document(msxsl:node-set($addxml)/ME/@id)/ME/FOURN/DEVOIR"/>

PS : I need to use a template because i have to calculate this sum for many
ME node-Set in my xml

Oups, at the moment i'm writing those lines, i tested the code more and more
and finaly it work !!!
I let the lines, maybe you'll tell me it can be improve ;)
Anyway, i now really understand what you meant :
I don't need reccurive template since msxsl:node-set($addxml)/ME/@id is a
node-set and document(this node-set) will go through all the documents
described in the node-set and then count(document(this node-set)/Xpath) will
count the total
amount on the whole documents. That's clear and incredibly powerfull and
quite fine !
One more time thanks a lot David, and sorry that i needed so much time to
understand the whole meaning of your solution.
Regards,
Matthieu.



-----Message d'origine-----
De : owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com]De la part de 
David
Carlisle
Envoyé : mardi 2 mars 2004 19:22
À : xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Objet : Re: [xsl] reccursive sum ?



  The goal of all this transformation is to prevent using a variable, is it
?
  I find it's a lot to do (it has many consequences on the whole project)
and
  don't see perfectly what the use of it.

why is it a lot to do? it just makes one variable which takes three or
four lines immediately before you call sum() as I showed in my post.


  document(concat($Meid,'.xml')

No, that makes the argument to document a string and you want it to be a
node set where each node has teh uri of a document, tehn document() will
load all the files in one go and sum() can take teh sum over all teh
files, as you requested.

If you don't do this, you'll ned to do a recursve template as I think
others have shown, which will certainly be a lot more code, it may or
may not be more efficient depending on implementation details of your
processor, however I'd guess usually it would be slower.

David



--
http://www.dcarlisle.demon.co.uk/matthew

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



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