for-each XPath sequence item, new V2 requirement ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

for-each XPath sequence item, new V2 requirement ?

Romain Deltour
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.