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

The example Jim refers to doesn’t reprocess the output of the step, but
mine does. It produces output, and analyzes/changes it to expand it by
using recursive calls. So, if that is what you mean by output feedback,
than it surely is possible.

But perhaps you could explain in different words what you are actually
trying to achieve. Perhaps with a bit of example input and output, and
processing described in abstract, functional terms, rather than in

Kind regards,


*Van:* Costello, Roger L. []
*Verzonden:* donderdag 2 mei 2013 11:34
*Aan:* XProc Dev
*Onderwerp:* 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


          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?


*From:* James Fuller [ <>]
*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

hth, J

On Wed, May 1, 2013 at 10:20 PM, Geert Josten <> 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
til/utils.xpl. It does a recursive reading of a directory..

Kind regards,

> -----Oorspronkelijk bericht-----
> Van: Costello, Roger L. []
> Verzonden: woensdag 1 mei 2013 21:36
> Aan:
> 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
>     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
> 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
> simply hand it off to XSLT to implement the recursive processing.
> /Roger
> [1]

Received on Thursday, 2 May 2013 10:07:43 UTC