RE: [xsl] mixing recursive template calls and for-each

Subject: RE: [xsl] mixing recursive template calls and for-each
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Thu, 4 Jul 2002 09:09:31 +0100
> 
> Here his an example of the template i could manage to write...
> 
>    <xsl:template match="place:list-of">
>      <!-- the node to iterate on -->
>      <xsl:variable name="node" select="@node" />
>      <!-- the nodes which are not under source node, that 
> will be copied -->
>      <xsl:variable name="present"
>                    select=".//*[not( ancestor-or-self::source)]" />
>      <!-- iterate on workitems -->
>      <xsl:for-each select="source//*[name() = $node]">
>        <!-- keep info on the current workitem -->
>        <xsl:variable name="currentWI" select="xalan:nodeset(.)" />
>        <!-- go through the nodes to treat -->
>        <xsl:for-each select="$present">
>          <xsl:choose>
...
> 
>    Here is my problem, for each given node under <source>, i 
> would like 
> to generate the tags inside place:list-of and at the same time change 
> place:value-of for the corresponding value.
> 
>    Of course, <place:list-of> is intended to be generic and 
> should work 
> for any tags under <source> and i don't know at what depth i 
> will find 
> <place:value-of> tags...
> 
First principle: if you want to write XSLT code that can handle
variability of structure, don't use <xsl:for-each>, use template rules
and <xsl:apply-templates/>.

I'm afraid I haven't had time to look at your particular problem in
depth.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 


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


Current Thread