Re: compound steps and primary inputs

I understand what a primary input port is.  What I don't know is how I know
that p:for-each has only one input.  If I look at a step like p:filter, it's
obvious from it's declaration (I'm catching on to the terms!) that it has
only one input port:

<p:declare-step type="p:filter">
     <p:input port="source"/>
     <p:output port="result" sequence="true"/>
     <p:option name="select" required="true"/>                     <!--
XPathExpression -->
</p:declare-step>

But p:for-each doesn't seem to have a declaration.  It looks sorta like
BNF/parser-token-stuff to me.  So what tells me that p:for-each has only one
input?

<p:for-each
  name? = NCName>
    ((p:iteration-source? &
      (p:output |
       p:log)*),
     subpipeline)
</p:for-each> 

James Garriss
http://garriss.blogspot.com




From: Norman Walsh <ndw@nwalsh.com>
Date: Tue, 23 Sep 2008 16:45:22 -0400
To: XProc Dev <xproc-dev@w3.org>
Subject: Re: compound steps and primary inputs
Resent-From: XProc Dev <xproc-dev@w3.org>
Resent-Date: Tue, 23 Sep 2008 20:46:27 +0000

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 Wednesday, 24 September 2008 12:55:16 UTC