Re: compound steps and primary inputs

James Garriss <james@garriss.org> writes:

> Do all compound steps have primary inputs?  I ask because I can't tell by
> reading the WD if p:for-each has a primary input or not.  I'm probably
> missing a key word somewhere.

The p:for-each step has only one input and the rules say 

  [Definition: If a step has a document input port which is explicitly
  marked “primary='true'”, or if it has exactly one document input
  port and that port is not explicitly marked “primary='false'”, then
  that input port is the primary input port of the step.]

By the second clause, the input port of p:for-each is primary.

> When I use it in Calabash 0.6.1, it behaves as if it does:
>
> <p:declare-step xmlns:p="http://www.w3.org/ns/xproc">
>     <p:input port="source">
>         <p:document href="BookStore.xml"/>
>     </p:input>
>     <p:output port="result"/>
>     <p:filter select="/BookStore/Book[Date>'1970']"/>
>     <p:for-each>
>         <p:output port="result"/>
>         <p:identity/>
>     </p:for-each>
> </p:declare-step>
>
> The output of filter, a sequence of documents (<Book>...</Book>), is being
> inputted (is that a word?) into p:for-each.

That's right. And that's what you want, isn't it?

> Appreciate any insights!

1. You only need to use p:filter if some part of the expression you want
to test against is computed by the pipeline. 

2. A p:for-each that contains only an identity step is a little, uh,
redundant.

I believe that you could simplify the pipeline above to just this:

<p:declare-step xmlns:p="http://www.w3.org/ns/xproc">
    <p:input port="source">
        <p:document href="BookStore.xml"/>
    </p:input>
    <p:output port="result"/>
    <p:identity select="/BookStore/Book[Date>'1970']"/>
</p:declare-step>

                                        Be seeing you,
                                          norm

-- 
Norman Walsh <ndw@nwalsh.com> | If we lived alone in a featureless
http://nwalsh.com/            | desert we should learn to place the
                              | individual grains of sand in a moral or
                              | aesthetic hierarchy.--Michael Frayn

Received on Tuesday, 23 September 2008 20:46:26 UTC