XIncludes, was: Re: [Petal] Petal 0.80 released
    Jean-Michel Hiver 
    jhiver at mkdoc.com
       
    Mon Jan 27 17:19:37 GMT 2003
    
    
  
> > Problem is that Petal is absolutely fine with recursive includes. So
> > maybe if we were to implement XIncludes we should ignore that bit of the
> > specification.
> 
> My reading of that spec says that the processor should abort if it
> goes into a loop condition. This seems like the proper behavior as I
> cannot envision a situation where recursive includes could be anything
> but an infinite loop.
> 
> Doc A ---> Doc B ---> Doc C ---> Doc B ---> Doc C ---> Doc B .....
That's because you're used to looping through SQL results rather than
traversing tree-like structures I think :)
Consider the following pseudo-code:
  DISPLAY_RECURSE (node) :
    print_node (node)
    if (node.children.length > 0)
       indent
       for each node in node.children
         DISPLAY_RECURSE (node)
       end-for
       unindent
    end-if
    
Well, with Petal it's possible :-) Look:
  <!--? file display-recurse.html --> 
  <li>
    <span petal:replace="node/title" />
  
    <ul petal:define="children node/children"
        petal:condition="children"
        petal:repeat="node children">
      <xi:include file="display-recurse.html" />
      
    </ul>
  </li>
Here the big trick is basically the petal:condition="children" statement
which will continue including until a certain condition is met (here,
the node has no children).
I hope this makes sense for everybody.
Best Regards,
-- 
Building a better web - http://www.mkdoc.com/
---------------------------------------------
Jean-Michel Hiver
jhiver at mkdoc.com  - +44 (0)114 255 8097
Homepage: http://www.webmatrix.net/
    
    
More information about the Petal
mailing list