Re: vnext: Idle musings about choose/when

Sorry for the delayed response. I was busy deterring would-be customers 
at Frankfurt Book Fair.

We have gotten used to the requirement, but I remember that initially I 
was bothered by the extra verbosity that it entails.

An alternative is to allow declaring outputs in the p:choose itself, like

<p:choose>
   <p:output port="secondary" sequence="true"/>
   <p:output port="report">
     <p:inline>
       <c:ok/>
     </p:inline>
   <p:output>
   <p:output port="foo">
     <p:document href="bar.xml"/>
   <p:output>
   …
</p:choose>

where each output port declaration in p:choose sets a default that may 
be overwritten in the p:when and p:otherwise branches.

A detail that remains to be specified is: If you refer to <p:pipe 
step="some-step" port="some-port"/> in one of these default 
declarations, does 'some-step' have to be in scope in the p:choose 
itself or may it be a step that is in scope in each of the p:when and 
p:otherwise branches? I think in order to reduce complexity for both 
processor developers and pipeline authors, all p:choose/p:output/p:pipe 
bindings must refer to a step that is in scope in the p:choose.

What is probably good about this approach: It’s syntactic sugar that can 
effectively reduce verbosity in quite common situations while still 
enforcing diagnostic feedback for inadvertently omitted outputs.

One drawback is that it does not reduce as much verbosity as your 
suggestion does for common cases. And it is yet another place where 
people may declare outputs, potentially creating more confusion than 
saving keystrokes. However, I think this kind of default declaration is 
quite intuitive. On the other hand, what I find intuitive about XProc 
pipelines might be entirely arcane to newbies. So others might also want 
to weigh in…

Gerrit

On 18.10.2016 15:12, Norman Walsh wrote:
> Hello world,
>
> How much of an inconvenience is the requirement that all branches of a
> choose/when have the same signature?
>
> Suppose we eliminated that rule.
>
> <p:choose name="run-stuff">
>   <p:when test="not($moon-is-full) or ($today != $tuesday)">
>     <p:output port="result" primary="true"/>
>     <p:output port="secondary" step="xslt"/>
>     <p:xslt name="xslt">…</p:xslt>
>   </p:when>
>   <p:otherwise>
>     <p:output port="result"/>
>     <p:identity>
>       <p:document href="not-today.xml"/>
>     </p:identity>
>   </p:otherwise>
> </p:choose>
>
> Three new rules:
>
> 1. An explicit binding to an output port on a p:choose is allowed as
> long as at least one of its branches defines a port with that name.
> That means <p:input step="run-stuff" port="secondary"/> is ok,
> but <p:input step="run-stuff" port="fribble"/> is a static error.
>
> 2. A p:choose has a primary output port if-and-only-if all of the
> branches have a primary output port with the same name. So this choose
> does have a primary output port: "result".
>
> 3. Any choose output that is not provided by the branch actually
> evaluated at runtime gets an empty sequence. That means that
> when the moon is full on Tuesdays,
> <p:input step="run-stuff" port="secondary"/> gets an empty sequence.
>
> We could relax rule 1 further and say any binding is allowed, but
> that doesn’t seem like it would be helpful to the author.
>
> We could relax rule 2 further and say that it has a primary output
> port if any of its branches do. But that would have consequences that
> seem extra weird to me. The primary output port is a convenience, it
> can always be replaced by an explicit binding. But if we relaxed rule
> 2 so that any output that was primary in the selected branch was
> bound, then that would no longer be true as the primary outputs might
> have different port names in the different branches.
>
>                                         Be seeing you,
>                                           norm
>

-- 
Gerrit Imsieke
Geschäftsführer / Managing Director
le-tex publishing services GmbH
Weissenfelser Str. 84, 04229 Leipzig, Germany
Phone +49 341 355356 110, Fax +49 341 355356 510
gerrit.imsieke@le-tex.de, http://www.le-tex.de

Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930

Geschäftsführer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard Vöckler
------------------------------------------------------------------------------
Meet us at Frankfurt Book Fair:
Hall 4.2, Stand L68.
More info at http://www.le-tex.de/en/buchmesse.html

Received on Thursday, 20 October 2016 21:21:13 UTC