Re: [xsl] reccursive sum ?

Subject: Re: [xsl] reccursive sum ?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 2 Mar 2004 11:15:40 GMT
		<xsl:variable name="ThisMEid">
			<xsl:value-of select="@id"/>
		</xsl:variable>

don't use xsl:variable with content unless your really need that
you can just go
		<xsl:variable name="ThisMEid" select="@id"/>
which is more efficient and more flexible as teh variable then holds an
attribute rather than a result tree fragmment.
In this case you don't need a variable at all, just go
<xsl:with-param name="MEid" select="@id"/>

Similarly you don't need MEfile you can just go

	<xsl:value-of
	select="count(document(concat($Meid,'.xml'))/ME/FOURN/DEVOIR"/>

If you could change your input to

<LISTE-ME>
	<ME id="0010.xml"/>
	<ME id="0045.xml"/>
	<ME id="0152.xml"/>
</LISTE-ME>

then you would not need teh concat above, just use

	<xsl:value-of
	select="count(document($Meid)/ME/FOURN/DEVOIR"/>


could use the following to get the total

	select="count(document(ME/@id)/ME/FOURN/DEVOIR"/>

But unfortunately using concat produces a string which stops document()
automatically taking the union of all the documents in the node set.

In XSLT1 the easiest way if you can not change your input format is
probably to do one pass into a variable that changes all the 
<ME id="0010"/> in to <ME id="0010.xml"/>
then use your processor's node-set() extension function to
apply templates to this new input as above.

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


Current Thread