You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Sebastian Klamar <se...@tux.wh17.tu-dresden.de> on 2003/11/29 09:35:28 UTC

repeat-until for Sitemap Logic -- better solution?

Is there any sitemap logic like a repeat-until statement Cocoon offers?
(Matchers work like if-then, Selectors like switch-case, with Actions you
can also simlutate a if-then afaik...)

I need to concatenate the same pipeline several times.  How often you
concatenate is not static (so I cannot place pipeline sequence several
times into sitemap.xmap).  Afterwards you have examined the output at
the end of the pipeline you decide whether you have ti go back to the
beginning of the pipeline where you inject the SAX stream the same
pipeline generated before.  So in programming language you would use
something like

  input = previousPipeline();
  repeat {  
    output = transformA(input);
    input = output;
    output = transformB(input);
    input = output;
  } until (out.isOkay());

My current solution uses Flowscript.  The pipeline inside
the repeat-until block gets called several times via Flow's
processPipelineTo().  Flow only gets a byte stream as output which I
cant inject into the next call of the pipeline.  Therefore I write
the SAX stream at the last stage of the pipeline to a transient store
(working like FragmentExtractorTransformer) and write the id into a
session variable.  The id is used to call the pipeline the next time
which can refer to the id to get the SAX stream from the last iteration?
Also at the very last stage of the pipeline the decision whether a next
iteration is need gets written as a session variable.

Do you know any better solution?  I don't like the use of the two session
variables to simulate concatenation and the decision making at the end
of the loop.


TIA -- Sebastian

-- 
Die letzten Worte...
      des Politikers: "...und wenn ich gewählt werde, verspreche ich..."
************************************************************************
PGP Key: 0x1E727CE6 / 9085 48BD 8332 4BFC D80C  A6CF D162 20BB 1E72 7CE6

RE: repeat-until for Sitemap Logic -- better solution?

Posted by Conal Tuohy <co...@paradise.net.nz>.

> -----Original Message-----
> From: Sebastian Klamar
> [mailto:sebi+lists.cocoon-users@tux.wh17.tu-dresden.de]
> Sent: Saturday, 29 November 2003 21:35
> To: Cocoon User Mailinglist
> Subject: repeat-until for Sitemap Logic -- better solution?
>
>
> Is there any sitemap logic like a repeat-until statement
> Cocoon offers?
> (Matchers work like if-then, Selectors like switch-case, with
> Actions you
> can also simlutate a if-then afaik...)

You can replace iteration with recursion, like you would in XSLT.

To make a recursive call in the sitemap, a transformer in your "foo"
pipeline decides to create an Xinclude or cinclude element referring to
"cocoon:/foo?next-step=bar", which are then resolved using an include
transformer, thus calling the pipeline again.

I've used this technique a few times, including to aggregate content from
several web pages (i.e. web crawling) into a single document.

Cheers

Con


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org