Re: The defaulting story

Hi,

Henry S. Thompson wrote:
> My earlier suggestions about this had depended on a notion of
> 'primary' inputs and outputs. . .  But no such notion is currently
> defined.  I feel like it might be useful in other ways. . .

I'd also like to get away from using the names of ports as the basis of 
defaulting, and rather use the notion of 'primary' inputs and outputs.

Here's a proposal:

Each element representing a language construct (<p:pipeline>, 
<p:for-each>, <p:viewport>, <p:choose>, <p:group>, <p:try>) plus 
<p:declare-step-type> has two attributes:

  * primary-input:  specifies name of primary input,
                    defaults to 'source'
  * primary-output: specifies name of primary output,
                    defaults to 'result'

[Note: Alternative design would be to have a 'primary' attribute on 
<p:input>/<p:output>, but then you'd have to check that only one 
input/output had primary="yes"...]

Taking Norm's original pipeline, with these attributes added:

<p:pipeline name="fig1"
	    xmlns:p="http://www.w3.org/2006/11/pipeline"
             primary-input="source"
             primary-output="result">
   <p:input port="source" sequence="no"/>
   <p:input port="schemaDoc" sequence="yes"/>
   <p:output port="result" sequence="no">
     <p:pipe step="s2" port="result"/>
   </p:output>

   <p:step type="p:xinclude" name="s1">
     <p:input port="source">
       <p:pipe step="fig1" port="source"/>
     </p:input>
   </p:step>

   <p:step type="p:validate" name="s2">
     <p:input port="source">
       <p:pipe step="s1" port="result"/>
     </p:input>
     <p:input port="schema">
       <p:pipe step="fig1" port="schemaDoc"/>
     </p:input>
   </p:step>
</p:pipeline>

I propose the following rules:

0. The 'sequence' attribute defaults to 'no'.

<p:pipeline name="fig1"
	    xmlns:p="http://www.w3.org/2006/11/pipeline"
             primary-input="source"
             primary-output="result">
   <p:input port="source" />
   <p:input port="schemaDoc" sequence="yes"/>
   <p:output port="result">
     <p:pipe step="s2" port="result"/>
   </p:output>

   <p:step type="p:xinclude" name="s1">
     <p:input port="source">
       <p:pipe step="fig1" port="source"/>
     </p:input>
   </p:step>

   <p:step type="p:validate" name="s2">
     <p:input port="source">
       <p:pipe step="s1" port="result"/>
     </p:input>
     <p:input port="schema">
       <p:pipe step="fig1" port="schemaDoc"/>
     </p:input>
   </p:step>
</p:pipeline>

1. The 'step' attribute of <p:pipe> can be omitted. If the <p:pipe> 
appears in <p:output>, then the source is the last step in the nested 
subpipeline. If the <p:pipe> appears within a <p:step> that does not 
have a preceding sibling, then the source is the container of that 
component. Otherwise, the source is the immediately preceding component.

<p:pipeline name="fig1"
	    xmlns:p="http://www.w3.org/2006/11/pipeline">
   <p:input port="source" />
   <p:input port="schemaDoc" sequence="yes"/>
   <p:output port="result">
     <p:pipe port="result" />
   </p:output>

   <p:step type="p:xinclude" name="s1">
     <p:input port="source">
       <p:pipe port="source" />
     </p:input>
   </p:step>

   <p:step type="p:validate" name="s2">
     <p:input port="source">
       <p:pipe port="source" />
     </p:input>
     <p:input port="schema">
       <p:pipe step="fig1" port="schemaDoc"/>
     </p:input>
   </p:step>
</p:pipeline>

[Note: To make this work with <p:choose>, we'd need to define what the 
primary inputs for <p:when> and <p:otherwise> are. I suggest we use the 
context for the test on <p:when>, and the context specified for 
<p:choose> for <p:otherwise> (which will default to the preceding or 
container component as applicable).]

2. The 'port' attribute of <p:pipe> can be omitted. If the source 
component is an ancestor, then the default port is the primary input 
port for that component. Otherwise, the default port is the primary 
output port for the component.

<p:pipeline name="fig1"
	    xmlns:p="http://www.w3.org/2006/11/pipeline">
   <p:input port="source" />
   <p:input port="schemaDoc" sequence="yes"/>
   <p:output port="result">
     <p:pipe />
   </p:output>

   <p:step type="p:xinclude" name="s1">
     <p:input port="source">
       <p:pipe />
     </p:input>
   </p:step>

   <p:step type="p:validate" name="s2">
     <p:input port="source">
       <p:pipe />
     </p:input>
     <p:input port="schema">
       <p:pipe step="fig1" port="schemaDoc"/>
     </p:input>
   </p:step>
</p:pipeline>

[Note: I think it's useful to be able to default the 'step' and 'port' 
independently, rather than only being allowed to default the entire 
<p:pipe>. For example, it means you can reference the result of a 
non-immediately-preceding step more easily, or reference two outputs 
from the immediately preceding step.]

3. If a <p:input> or <p:output> has no content, then it is treated as if 
it contains a <p:pipe> with no attributes (which is then defaulted as 
above).

<p:pipeline name="fig1"
	    xmlns:p="http://www.w3.org/2006/11/pipeline">
   <p:input port="source" />
   <p:input port="schemaDoc" sequence="yes"/>
   <p:output port="result" />

   <p:step type="p:xinclude" name="s1">
     <p:input port="source" />
   </p:step>

   <p:step type="p:validate" name="s2">
     <p:input port="source" />
     <p:input port="schema">
       <p:pipe step="fig1" port="schemaDoc"/>
     </p:input>
   </p:step>
</p:pipeline>

[Note: This defaulting step means that we can't use an empty 
<p:input>/<p:output> to mean an empty sequence of documents. I think we 
might want to introduce a <p:empty/> (or equivalent) element for that case.]

4. A component need not be named if there are no references to that name.

<p:pipeline name="fig1"
	    xmlns:p="http://www.w3.org/2006/11/pipeline">
   <p:input port="source" />
   <p:input port="schemaDoc" sequence="yes"/>
   <p:output port="result" />

   <p:step type="p:xinclude">
     <p:input port="source" />
   </p:step>

   <p:step type="p:validate">
     <p:input port="source" />
     <p:input port="schema">
       <p:pipe step="fig1" port="schemaDoc"/>
     </p:input>
   </p:step>
</p:pipeline>


5. The 'port' attribute of <p:input> defaults to the primary input for 
the component (whose default is 'source'). The 'port' attribute of 
<p:output> defaults to the primary output for the component (whose 
default is 'result').

<p:pipeline name="fig1"
	    xmlns:p="http://www.w3.org/2006/11/pipeline">
   <p:input />
   <p:input port="schemaDoc" sequence="yes"/>
   <p:output />

   <p:step type="p:xinclude">
     <p:input />
   </p:step>

   <p:step type="p:validate">
     <p:input />
     <p:input port="schema">
       <p:pipe step="fig1" port="schemaDoc"/>
     </p:input>
   </p:step>
</p:pipeline>

[Note: I'm not sure if this is confusing or helpful, but it's a default 
that we can specify cleanly, so I'm inclined to do so.]

6. Within <p:step>, the <p:input> corresponding to the primary input for 
that step can be omitted. In this case, the <p:step> is treated as if 
there were a <p:input> for the primary input (which is then defaulted as 
above).

<p:pipeline name="fig1"
	    xmlns:p="http://www.w3.org/2006/11/pipeline">
   <p:input />
   <p:input port="schemaDoc" sequence="yes"/>
   <p:output />

   <p:step type="p:xinclude" />

   <p:step type="p:validate">
     <p:input port="schema">
       <p:pipe step="fig1" port="schemaDoc"/>
     </p:input>
   </p:step>
</p:pipeline>

Cheers,

Jeni
-- 
Jeni Tennison
http://www.jenitennison.com

Received on Friday, 22 December 2006 14:46:05 UTC