[uf-discuss] Re: Optimus 0.5.1
Toby A Inkster
mail at tobyinkster.co.uk
Thu Apr 10 01:53:26 PDT 2008
Michael MD wrote:
> nested includes? !
> my guess is that anyone doing that would be asking for trouble!
This is another thing that Cognition has supported since alpha1. (Though
until the latest release it supported including a node's own parent, which
really *is* asking for trouble!)
The only thing you've got to be careful of (from a parser's POV) is making
sure that you don't get stuck in an infinite loop. The solution is to
write your inclusion code to *not* support nested includes, and then
simply call the function a few times. (The first call will handle
includes, then the second call will handle includes within includes, etc.)
My policy is to allow two levels of includes for adr and geo, 4 levels for
hCalendar valarm and hCalendar vfreebusy, and 6 for hCard, hAtom entries,
hCalendar vevent and hCalendar todo.
I also use an optimisation such that each call of the function actually
checks to see if any changes have been made. If no changes have been made,
then the loop is ended prematurely -- this prevents the inclusion code
(which is computationally expensive) from being called when there are no
instances of class="include" left, or those instances are invalid (e.g.
attempts to include an ancestor node).
--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 14 days, 19:59.]
Tagliatelle with Fennel and Asparagus
http://tobyinkster.co.uk/blog/2008/04/06/tagliatelle-fennel-asparagus/
More information about the microformats-discuss
mailing list