Re: [xsl] recursivity and param

Subject: Re: [xsl] recursivity and param
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 12 Aug 2004 12:05:30 +0100
> when I pass context to a certain
> child I would like to take in account things that happened before while
> processing children I met before (in order of source document for example).
 
When writing your XSLT it's best to assume that you are writing for a
massively parallel system that is going to evaluate all the templates on
child nodes at the same time, return the results in some random (in
time) order, and then this template assembles the results as they come in
and writes out the result for this template based on document source
order, irrespective of the order in which the templates applied to
children were executed.

It is just possible that in fact that isn't what happens and that you
have a serial machine and your processor always executes templates
in an order derived from the document order of input nodes, but that is
an implementation detail than can never affect the programming
constructs.

So you see it isn't possible for a template to say "I'm the 10'th to be
processed" and stop the processing of other templates. If the language
did allow it you would get arbitrary results depending on teh order in
which teh system happened to 


>   - Suppose that I add a condition that I must not copy more than 10
>   <to-copy-element />. In other words I want to copy only the first (in order
>   of source document) 10 <to-copy-element /> elements or all the
>   <to-copy-element /> elements if count(//to-copy-element)<11.

If that's what you want to do, just select 10 such nodes, rather than
select them all and then try to make the 10'th stop processing.

<xsl:apply-templates select="to-copy-element[position() &lt;= 10]"/>

will just process the first 10 such children.

David

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

Current Thread