for-each XPath sequence item, new V2 requirement ?

Hi,

I have a use case where I want to load documents declared as a space-separated sequence of URIs in a step option. It occurred to me that there was no super-easy way to do that with vanilla XProc.

I ended up implementing a `px:tokenize` step which applies the XPath tokenize() function with the step's 3 options as arguments, and return the result as a sequence of `c:result` documents. See the implementation there:
   https://gist.github.com/rdeltour/6319457

Now, it made me want to be able to do this in XProc:

<p:for-each>
    <p:iteration-source select="tokenize($my-list,'\s+')"/>
    <!-- subpipeline processing the result sequence as `c:result` documents -->
</p:for-each>

In other words, what I'm thinking is allowing any XDM sequence as the iteration source of p:for-each (assuming vNext targets XPath 2.0):
 - if an item is a document node, pass it as-is to its sub pipeline
 - if an item is an element, pass it wrapped in a document
 - in any other cases, pass its string value as a `c:result` document

Thoughts ?

Romain.

Received on Friday, 23 August 2013 21:36:44 UTC