RE: choose with no default

The "Otherwise, nothing need be done" part still needs to be provided in
the pipeline - even if it really does "nothing". In your case, you will
have to add a p:otherwise branch to p:choose that might look something
like this:

<p:otherwise>
  <!-- do "nothing" with the source document -->
  <p:identity>
    <p:input port="source">
      <p:pipe port="result" step="text-fix"/>
    </p:input>
  </p:identity>
</p:otherwise>

There is no equivalent of XSLT's xsl:if in XProc that would do some
processing only if a certain condition is true. I agree that having
something like that in XProc would be nice and would definitely save a
lot of typing, but I am afraid that the original XSLT construct wouldn't
translate to XProc very well. There is a fundamental difference between
XSLT and XProc: In XSLT you use constructs such as xsl:if and
xsl:apply-templates to write to the result tree, whereas in XProc, you
are not writing anywhere; you are connecting steps. And when connecting
steps, you need to know where do the input ports of the steps read the
data from (output ports of other steps, external or inline documents
etc.).

With something like p:if, the steps connected to it would not know where
to read the input data from if the IF condition evaluated to false
(because the p:if step would not have been executed at all). And unless
the p:if step was modeled fundamentally different from other built-in
XProc steps (p:choose, p:for-each, p:group, ...), the XProc processor
would have no clue as to what to substitute for the result of the
not-executed p:if step. So you would have to provide some sort of
default anyway - which is what p:choose/p:when/p:otherwise does already.

Hope this helps (and that at least some of those English unreal
conditionals were grammatically correct :).

Vojtech


--
Vojtech Toman
Consultant Software Engineer
EMC | Information Intelligence Group
vojtech.toman@emc.com
http://developer.emc.com/xmltech

Received on Wednesday, 6 October 2010 12:13:02 UTC