Re: p:for-each without input documents

Hi Sheila,

I think you're mistaken.

It should be possible to iterate over a list of values. But: There must 
be a document on the DRP of the for-each. So something like this should 
work:

<p:for-each>
   <p:with-input select="(1, 2, 3)">
     <dummy/>
   </p:with-input>

   ...

</p:for-each>


I've done this in a  few pipelines (running on Morgana).

Regards,
Erik Siegel


On 22/05/2026 00:35, Sheila Thomson wrote:
> If I remember correctly, at the moment it's not possible to use 
> p:for-each to loop over a sequence of values; the input has to be an 
> element or document.
>
> However, I notice that per the current iteration of the (draft) XPath 
> 4.0 spec, it will be possible to construct a document node in an XPath 
> expression.  Would that mean that (if and when XPath 4.0 is supported 
> in XProc) the following (or something similar) would work instead?
>
> ```
> <p:variable name="test-suite-versions" 
> select="distinct-values(//test-suite/@version)" as="xs:string*" />
>
> <p:for-each>
>     <p:with-input select="for $version in $test-suite-versions return 
> document { <version>{$version}</version>}">
>     ...
> </p:for-each>
> ```
>
> Sheila
>

Received on Friday, 22 May 2026 08:14:01 UTC