W3C home > Mailing lists > Public > xproc-dev@w3.org > October 2011

RE: New to Xproc Question : conditionnal "output port" definition?

From: Geert Josten <geert.josten@daidalos.nl>
Date: Wed, 12 Oct 2011 12:42:35 +0200
To: Matthieu Ricaud-Dussarget <matthieu.ricaud@igs-cp.fr>, "XProc Dev (xproc-dev@w3.org)" <xproc-dev@w3.org>
Message-ID: <B26C615F8546A84C81165A7BC8BE61A020FC0F91EE@EXMBXC01.ms-hosting.nl>
Hi Matthieu,

It can be somewhat cumbersome to get inputs and outputs in choose alternatives in sync, so no surprise you stumble upon this problem. The problem is caused by a difference in the output port definitions of the last steps within the when's and otherwise. Your when (starts and) ends with a p:error, your otherwise ends with a p:store. P:store has a *non-primary* output, while p:error has a primary one. The output of p:error is automatically connected to the output of the p:choose.

You have a few options. You could try to connect the output of the store to the output of the p:otherwise, but it might be easier to add a step behind p:store to generate (primary) output, for instance using p:identity:

<p:identity>
	<p:input port="source">
		<p:empty/>
	</p:input>
</p:identity>

Even simpler is putting a step behind p:error to consume output, for instance using p:sink, causing when and otherwise to both have no (primary) output:

<p:sink/>

Since you say your declare-step has a p:output declared as empty, I'd say you want to use p:sink behind p:error. That sounds like the shortest solution.. ;-)

Kind regards,
Geert

-----Oorspronkelijk bericht-----
Van: xproc-dev-request@w3.org [mailto:xproc-dev-request@w3.org] Namens Matthieu Ricaud-Dussarget
Verzonden: woensdag 12 oktober 2011 12:25
Aan: XProc Dev
Onderwerp: New to Xproc Question : conditionnal "output port" definition?

Hi Xproc Folks !

I'm new to Xproc and I can't figure out how to deal with primary output 
port :

- I use <p:declared-step> as root element
- I fixed main <p:output port="result"> to <p:empty/> because I want to 
store each steps output in a debuging file with <p:store> (R. Castello 
says "Since we are writing to files with p:store, set the output to 
empty" in his tuto)
- I have a <p:choose> which can lead to <p:error> if a special condition 
is not satisfied.
- It seems I have to plug my main output port to the <p:choose> so that 
the errors is thrown and stop the process

See the choose step at the bottom of this mail.

Actually Calabash raises this error :
GRAVE: It is a static error if two subpipelines in a p:choose declare 
different outputs.

Does that means what I want to do "If (test) then (error) else 
(xslt+store)" is not possible ?
Is there a way to achieve this "process" ?

Any help, tips welcome !

Matthieu

The choose step code :

<p:choose name="stop_if_viewport_inconsistence">
<p:when 
test="count(distinct-values(/igs:aggregate/doc/pages/page/@viewportX))!=1">
<p:error name="viewport_err" code="viewport_err">
<p:input port="source">
<p:inline>
<message>viewports inconsistence here !</message>
</p:inline>
</p:input>
</p:error>
</p:when>
<p:otherwise>
<p:xslt name="generateECF">
<p:input port="source">
<p:pipe step="add-viewport" port="result"></p:pipe>
</p:input>
<p:input port="stylesheet">
<p:document href="../xslt/generateECF.xsl"/>
</p:input>
<p:input port="parameters"><p:empty/></p:input>
</p:xslt>
<p:store encoding="UTF-8" omit-xml-declaration="false" indent="true">
<p:with-option name="href" 
select="concat(/ecf:content/opf:metadata/dc:identifier[@id=parent::opf:metadata/@unique-identifier],'.ecf')"></p:with-option>
</p:store>
</p:otherwise>
</p:choose>

With
<p:output port="result">
<p:empty/>
</p:output>
at the beginning.

-- 
Matthieu Ricaud
IGS-CP
Service Livre numérique
Received on Wednesday, 12 October 2011 10:43:03 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 12 October 2011 10:43:03 GMT