W3C home > Mailing lists > Public > xproc-dev@w3.org > February 2011

Re: Handle the first document in a sequence

From: Hans-Juergen Rennau <rennau@bits-ac.com>
Date: Wed, 02 Feb 2011 09:09:56 +0100
Message-ID: <4D491154.8050007@bits-ac.com>
To: Florent Georges <fgeorges@fgeorges.org>, XProc Dev <xproc-dev@w3.org>, philip.fennell@marklogic.com
Hi Georges and Philip,

perhaps the simplest approach is to use p:split-sequence? That is 
possible as when evaluating the 'test' option, position() is set to the 
position of the document in the sequence.

So, for example, the following pipeline emits documents 1 and 3 - see below.

If actually desiring the first n elements only, this can be combined 
with setting the 'initial-only' option to 'true', with possible 
performance gain. (Who knows.)

Kind regads,
Hans-Juergen


<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="1.0">
<p:input port="source">
<p:inline><one/></p:inline>
<p:inline><two/></p:inline>
<p:inline><three/></p:inline>
</p:input>
<p:output port="result" sequence="true">
<p:pipe port="matched" step="getByPosition"/>
</p:output>

<p:split-sequence name="getByPosition" test="position() = (1,3)"/>
</p:declare-step>



Am 02.02.2011 01:36, schrieb Florent Georges:
>    Hi,
>
>    I have a step that looks like the following:
>
>      <p:declare-step type="..." name="mine">
>         <p:input port="doc" primary="true"/>
>         <p:input port="seq" sequence="true"/>
>         <p:store>
>            <p:input port="source">
>               <p:pipe port="seq" step="mine"/>
>            </p:input>
>         </p:store>
>         ...
>
>    Basically, it declares 2 ports: one is the primary, and the
> other accepts a sequence of documents.  It has to store the first
> document in the sequence.  Of course, the above excerpt is wrong,
> because the source port of p:store does not accept sequences.
>
>    How can p:store access only to the first doc?
>
>    I thought about using p:for-each and p:iteration-position() (to
> test if the current doc is the first doc), but I thought there
> must be something simpler.
>
>    Did I miss something?  Regards,
>
Received on Wednesday, 2 February 2011 08:25:41 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 2 February 2011 08:25:41 GMT