Re: Composability

Norman Walsh wrote:
> / Jeni Tennison <jeni@jenitennison.com> was heard to say:
> | * the lack of composability (i.e. that you can't simply wrap any given
> | step in a pipeline, exposing the same signature, and have it work, but
> | fixing that would take a fair amount of time, effort and willingness
> | to change, which I don't think we have)
> 
> I'll probably feel stupid when I hear the answer, but which part
> doesn't work?

Namespaces and options. Say you have a pipeline that includes:

   <p:matching-documents xmlns:my="http://www.example.com/ns/jeni">
     <p:option name="test" value="/my:foo[@bar = $bar]" />
   </p:matching-documents>

the namespaces and in-scope options from the calling context are passed 
to the <p:matching-documents> step so that it can interpret the XPath in 
its test option. In this case, the 'my' prefix is bound to the namespace 
'http://www.example.com/ns/jeni' and the $bar variable is set from the 
calling environment.

Now wrap it in a pipeline:

<p:pipeline name="jt:matching-documents"
   xmlns:jt="http://www.example.com/ns/jeni">
   <p:input port="source" sequence="yes" />
   <p:output port="result" sequence="yes" />
   <p:option name="test" required="yes" />
   <p:matching-documents>
     <p:option name="test" select="$test" />
   </p:matching-documents>
</p:pipeline>

and call this new pipeline in the same way as before:

   <my:matching-documents xmlns:my="http://www.example.com/ns/jeni">
     <p:option name="test" value="/my:foo[@bar = $bar]" />
   </my:matching-documents>

The value '/my:foo[@bar = $bar]' is passed as the value of the test 
option to <jt:matching-documents> as a string. But in my pipeline, where 
<p:matching-documents> is called, there's no binding for the 'my' 
prefix, nor for the $bar in-scope option, so the pipeline fails.

If we had the time/will to do something about this, it would mean having 
a way of capturing the namespace bindings and in-scope options that are 
passed through to the pipeline step, and passing them on (selectively) 
to the contained steps. We could do it in the same way as I've suggested 
for parameters, since really it's the same problem.

Personally, I see this as an absolutely fundamental part of building a 
robust, scalable language. But I imagine most people see it as an edge 
case and I'm not going to push it.

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

Received on Tuesday, 29 May 2007 08:17:45 UTC