Re: Handle the first document in a sequence

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 UTC