Re: choose with no default

Thanks Vojtech (and others).

I'd already worked out that I need to put an identity into a p:otherwise. What I was wondering was if there was a more 'idiomatic' solution. The issue here for me really is that I have a long process that ends with about 10 different p:xslt, p:store pairs so there is nothing much to pass along to the next stage. 

If it's of interest to anyone I actually ended up using the following:



    <!-- generate the dedication. -->
    <p:for-each>

        <p:iteration-source select="/db:book/db:dedication">
            <p:pipe port="result" step="text-fix"/>
        </p:iteration-source>

        <cstep:create-dedication>
            <p:input port="source">
                <p:pipe port="result" step="text-fix"/>
            </p:input>
            <p:with-option name="xhtml-path" select="$xhtml-path"/>
        </cstep:create-dedication>

    </p:for-each>

which strikes me as 'cheating' but works for me.

cheers

nic


On 6 Oct 2010, at 13:11, <vojtech.toman@emc.com> <vojtech.toman@emc.com> wrote:

> 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
> 
> 
> 

--
Nic Gibson
Corbas Consulting
Digital Publishing Consultancy and Training
http://www.corbas.co.uk, +44 (0)7718 906817	
	

Received on Wednesday, 6 October 2010 12:44:23 UTC