RE: Is there a way to implement feedback loops in XProc?

Thank you very much Geert and Jim.

I have been studying the pipeline that Jim referenced. From what I understand, the pipeline is doing recursion.

In pseudocode this appears to be what the pipeline is doing:

replicate (count, item)
     if count = 1 then output item
     else
          replicate (count-1, item)
          output item

Is that correct?

So recursion is possible in XProc, as long as there is no output feedback. Is that correct?

/Roger

From: James Fuller [mailto:jim@webcomposite.com]
Sent: Wednesday, May 01, 2013 4:22 PM
To: Geert Josten
Cc: Costello, Roger L.; XProc Dev
Subject: Re: Is there a way to implement feedback loops in XProc?

here is another somewhat simpler data point

https://github.com/innovimax/xproc/blob/master/fizzbuzz.xpl

hth, J

On Wed, May 1, 2013 at 10:20 PM, Geert Josten <geert.josten@dayon.nl<mailto:geert.josten@dayon.nl>> wrote:
Hi Roger,

You can't tie the output of a step to the input of the same step, but you
can add a step as a child of itself. Just make sure you wrap it in some
conditional to terminate recursion.

Perhaps not the most lucid example, but you could take a look at
expand-dirs in
https://github.com/grtjn/xproc-ebook-conv/blob/master/src/nl/grtjn/xproc/u
til/utils.xpl. It does a recursive reading of a directory..

Kind regards,
Geert

> -----Oorspronkelijk bericht-----
> Van: Costello, Roger L. [mailto:costello@mitre.org<mailto:costello@mitre.org>]
> Verzonden: woensdag 1 mei 2013 21:36
> Aan: xproc-dev@w3.org<mailto:xproc-dev@w3.org>
> Onderwerp: Is there a way to implement feedback loops in XProc?
>
> Hi Folks,
>
> The spec says [1] that no feedback loops are allowed in an XProc
pipeline:
>
>     It is a static error (err:XS0001) if there
>     are any loops in the connections between
>     steps: no step can be connected to itself
>     nor can there be any sequence of connections
>     through other steps that leads back to itself.
>
> So how are recursive structures processed?
>
> As a simple example, suppose "Section" is defined recursively:
>
> Section = Title | Title Section
>
> If XProc supported feedback loops I would create a step in the pipeline
that
> processes the content of a Section and the output is the nested Section,
> which is is fed back around to the step:
>
> ---> Step (process Section content) ----------
> ^                                                                     |
> |                                     |
> -------<--------<------------------<-----------<----
>                   (nested Section)
>
> Since feedback loops are not allowed, how is this type of thing
> accomplished in XProc? Note: I need to implement this using XProc and
not
> simply hand it off to XSLT to implement the recursive processing.
>
> /Roger
>
> [1] http://www.w3.org/XML/XProc/docs/langspec.html#connections

Received on Thursday, 2 May 2013 09:34:54 UTC