Slight inconvenience of using only @select for options

Hi all,

I just observed that the removal of the @value attribute from p:option
makes using options a bit cumbersome in some cases.

The problem can be illustrated on this (old syntax, uses the @value
attribute) pipeline:

<p:identity>
  <p:input port="source" select="//chapter"/>
</p:identity>
<p:wrap-sequence>
  <p:with-option name="wrapper" value="book"/>
</p:insert>

With the new syntax, the pipeline must be rewritten as follows:

<p:identity>
  <p:input port="source" select="//chapter"/>
</p:identity>
<p:wrap-sequence>
  <p:with-option name="wrapper" select="'book'">
    <p:empty/>
  </p:with-option>
</p:insert>

The empty binding for the "wrapper" option is necessary otherwise the
option is bound to the default readable port (section 5.7.3) which
produces a sequence of documents which in turn causes a dynamic error
XD0008. In other words, the following does not work (unless p:identity
produces exactly one document):

<p:identity>
  <p:input port="source" select="//chapter"/>
</p:identity>
<p:wrap-sequence>
  <p:with-option name="wrapper" select="'book'"/>
</p:insert>


I am not saying the described behaviour is wrong, but it can be a bit
awkward that you will have to specify p:empty binding very often to
prevent dynamic errors. As I see it, here is a sort of a 'conflict'
between two types of XPath expresions:

- Expressions that actually query the content (for instance: //book). In
this case, you probably want the option to be bound to the default
readable port automatically (current behaviour)
- Expression that do not query the content (for instance: 'true' or:
p:system-property('p:language')). In that case, the binding does not
matter (and can be empty).

I don't know which type of XPath expressions will be more frequent in
XProc, but since most options take simple boolean or string values,
perhaps the sentence in 5.7.3 can be changed to something like:

"If a select expression is used but no document binding is provided, an
empty document is used as the context node."

In other words, if you want to query content in your XPath expression,
you will have to provide an explicit p:pipe, p:inline or p:document
binding. But I am not sure whether such change would actually improve
anything.

The same applies also to variables and parameters.

Any thoughts?


Regards,
Vojtech

--
Vojtech Toman
Principal Software Engineer
EMC Corporation

Aert van Nesstraat 45
3012 CA Rotterdam
The Netherlands

Toman_Vojtech@emc.com

Received on Wednesday, 23 April 2008 08:25:00 UTC