Re: an idea: ports == options

I like this idea, but we can do even better: ports inputs/outputs (=
options) and variables should be more easily interchangeable, like
parameters and variables in XSLT.
Also, the way to refer to ports, variables, XPath expression should be
more homogeneous (let's build on top of XSLT & XQuery).
Especially if we use XDM values and XPath 3.

In XSLT, $x can be either a parameter or a variable, and this is very
convenient when you want to "promote" a variable to a parameter (at
the XSLT or function level), or "downgrade" a parameter to a variable.
I use this a lot for prototyping and debugging, It is also very
convenient for refactoring.

I'd like to be able to do the same in XProc:
using $x, where x can be
- the input/output/options of a step
- a variable
with a syntax of this kind:
<p:bind name="source" to="$x"/>

For example:
1)
<p:bind name="some-item" to="$x/result"/>
 where "x" is the name of a pipe with a port named "result"

2)
<p:bind name="some-item" to="$x"/>
where "x" is a variable

3)
<p:xslt name="step-1">
   …
</p:xslt>
<p:identity>
    <p:bind name="source" to="$previous/secondary"/>
<p:identity/>

would be equivalent to:
<p:xslt name="step-1">
   …
</p:xslt>
<p:identity>
    <p:bind name="source" to="$step-1/secondary"/>
<p:identity/>

This way, we are still able to specify the binding to a specific port.
(the use case is: to add a p:xslt step without having to change the
name of the step in p:identity)

4) (if steps options are defined as a map())
<p:store name="store-html" href="…" encoding="utf-8">
   …
</p:store>
…
<p:message select="'string($store-html/result) || ' serialized as ' ||
get($store-html/options, 'encoding')">
   …
</p:store>

-- 
Olivier

Received on Monday, 17 February 2014 14:08:44 UTC