velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Esterline <Ad...@cait.wustl.edu>
Subject Recursion
Date Wed, 07 Aug 2002 21:57:42 GMT
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

<course>
  <name>$course.name</name>
  <code>$course.code</code>
  <category>$course.category.name</category>
  <super_cat>$course.category.superCategory.name</super_cat>
  <description>$course.description</description>
  <comment>$course.comment</comment>
  <prerequisites>
  #foreach( $prereq in $course.prerequisites )
      <prerequisite>$prereq.code</prerequisite>
  #end
  </prerequisites>
  <audience>$course.audience</audience>
  <duration>$course.duration</duration>
  <objectives>
  #foreach( $obj in $course.currentObjectives )
    <objective>$obj</objective>
  #end
  </objectives>
  <outline>
    #foreach( $kid in $course.outline.children )
       #processNode( $kid )
    #end
  </outline>
  ## We do not have the revised field worked out yet.
  ## TODO: Find out what can be done to accomidate the revised field.
  <revised>6/18/01</revised>
</course>

The XML that is generated looks like this.

<course>
  <name>Developing MS Access Applications - I</name>
  <code>ACC200</code>
  <category>Access</category>
  <super_cat>Database</super_cat>
  <description>Microsoft Access is the premiere database management system
used today.  It allows someone with little database and programming
expertise to build a sophisticated application in a short amount of time.
In this course, students will learn to develop Microsoft Access applications
using the features of Microsoft Access, such as tables, queries, forms, and
reports.  Students will use Microsoft Access wizards and builders to
facilitate the development of their application, and learn how to modify
objects without using wizards.  They will learn about table relationships,
data validation, queries and form and report design.</description>
  <comment>Participants should be familiar with Access as end-users, or have
experience with another database.
</comment>
  <prerequisites>
    </prerequisites>
  <audience>This course is designed for students who want to learn to
develop Microsoft Access applications.</audience>
  <duration>3</duration>
  <objectives>
      <objective>Use database design principles to design an Microsoft
Access application.</objective>
      <objective>Use Microsoft Access features to build the
application.</objective>
      <objective>Use built-in wizards and builders to facilitate application
development.</objective>
    </objectives>
  <outline>
           <item>
   <text>Tables</text>
         <item>
   <text>Tables</text>
         <item>
   <text>Tables</text>
         <item>
   <text>Tables</text>
         <item>
   <text>Tables</text>
         <item>
   <text>Tables</text>
         <item>
   <text>Tables</text>
         <item>
   <text>Tables</text>
         <item>
   <text>Tables</text>
         <item>
   <text>Tables</text>
         <item>
   <text>Tables</text>
         <item>
   <text>Tables</text>
         <item>
   <text>Tables</text>
         <item>
   <text>Tables</text>
         <item>
   <text>Tables</text>
         <item>
   <text>Tables</text>
         <item>

....
</course>

As you can see I get too many outline items.   This list does eventually
quit, so it is not in an infinite loop.

Any help would be appreciated.

Adam

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