velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Esterline <Ad...@cait.wustl.edu>
Subject RE: Recursion
Date Thu, 08 Aug 2002 15:06:59 GMT
You are correct.   That is not what I want, but how do I work around it.

Adam

-----Original Message-----
From: plynchnlm@netscape.net [mailto:plynchnlm@netscape.net]
Sent: Thursday, August 08, 2002 9:57 AM
To: velocity-user@jakarta.apache.org
Subject: RE: Recursion


The Velocity documentation says that macro parameters are passed "by
name".  I think this means that if you called #processNode($a), the code
that would be run would be:

<item>
   <text>$a.text</text>
   #foreach( $child in $a.children )
      #processNode( $child )
   #end
</item>

But, when the recursive part starts, $child is passed as an argument,
so would you would get (I think) is this:

<item>
   <text>$child.text</text>
   #foreach( $child in $child.children )
      #processNode( $child )
   #end
</item>

which is almost certainly not what you wanted.

  --Paul


Adam Esterline <AdamE@cait.wustl.edu> wrote:

>No.   That still did not work.
>
>Adam
>
>-----Original Message-----
>From: lloyd [mailto:subscr001@twilight-systems.com]
>Sent: Wednesday, August 07, 2002 6:12 PM
>To: Velocity Users List
>Subject: Re: Recursion
>
>
>Adam Esterline wrote:
>> I have seen several posts about this issue, but I still don't understand.
>> Here is my example, could someone please explain why this does not work.
>> 
>> 
>> ## Macro for creating the outline XML
>> #macro( processNode $node )
>> <item>
>>    <text>$node.text</text>
>>    #foreach( $child in $node.children )
>>       #processNode( $child )
>>    #end
>> </item>
>> #end
>
>
>Wild guess:
>
>Have you tried getting a reference to children first:
>
>#(set $childNodes = $node.children )
>#foreach( $child in $childNodes )
>...etc
>
>?
>
>
>--
>To unsubscribe, e-mail:
><mailto:velocity-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail:
><mailto:velocity-user-help@jakarta.apache.org>
>
>--
>To unsubscribe, e-mail:  
<mailto:velocity-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail:
<mailto:velocity-user-help@jakarta.apache.org>
>
>


__________________________________________________________________
Your favorite stores, helpful shopping tools and great gift ideas.
Experience the convenience of buying online with Shop@Netscape!
http://shopnow.netscape.com/

Get your own FREE, personal Netscape Mail account today at
http://webmail.netscape.com/


--
To unsubscribe, e-mail:
<mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:velocity-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>


Mime
View raw message