Re: conditionally do something depending on whether there’s a document on the input port

Well p:for-each is really ugly. It reminds me of xsl:for-each misuse

I your really want to go the <p:empty/> way, I think the right way is to
use <p:count limit="1"/> followed by a <p:choose>
The other way is to make the output be some <foo:bar/> element in a funky
namespace and keep the choose you got at the beginning

The QuiXProc team


On Fri, Feb 22, 2013 at 12:32 AM, Imsieke, Gerrit, le-tex <
gerrit.imsieke@le-tex.de> wrote:

> Ok, I used p:for-each then:
>
>     <p:for-each name="conditionally-patch-**html">
>       <p:iteration-source>
>
>         <p:pipe port="html-in" step="validate-with-**schematron2"/>
>       </p:iteration-source>
>
> Gerrit
>
>
> On 21.02.2013 23:53, Imsieke, Gerrit, le-tex wrote:
>
>> I’ve developed a step that validates with Schematron and inserts the
>> validation messages into an HTML rendering of the validated document
>> (the document and the HTML rendering are passed to the step on
>> individual input ports). The step also takes as input the accrued
>> reports of other upstream Schematron validations and renders them, too.
>>
>> Because this operation is costly for large documents and when there are
>> many messages to patch into the document, I’d like to avoid this
>> patching procedure until the very last Schematron validation.
>>
>> So I though that if I send a <p:empty/> to the HTML input port for all
>> but the last invocations of my custom Schematron/patch step, I may be
>> able to conditionally avoid the costly operation:
>>
>>      <p:choose name="conditionally-patch-**html">
>>        <p:xpath-context>
>>          <p:pipe port="html-in" step="validate-with-**schematron2"/>
>>        </p:xpath-context>
>>        <p:when test="not(node())">
>>
>> ⇒
>>
>> SEVERE:
>> converter/xpl/validate-with-**schematron.xpl:157:34:err:**
>> XD0026:Expression
>> refers to context when none is available: boolean(not(node()))
>> Feb 21, 2013 11:28:18 PM com.xmlcalabash.drivers.Main error
>> SEVERE: It is a dynamic error if the select expression makes reference
>> to the context node, size, or position when the context item is undefined.
>>
>> How can I test whether there’s no document on an input port?
>>
>> Gerrit
>>
>>
> --
> Gerrit Imsieke
> Geschäftsführer / Managing Director
> le-tex publishing services GmbH
> Weissenfelser Str. 84, 04229 Leipzig, Germany
> Phone +49 341 355356 110, Fax +49 341 355356 510
> gerrit.imsieke@le-tex.de, http://www.le-tex.de
>
> Registergericht / Commercial Register: Amtsgericht Leipzig
> Registernummer / Registration Number: HRB 24930
>
> Geschäftsführer: Gerrit Imsieke, Svea Jelonek,
> Thomas Schmidt, Dr. Reinhard Vöckler
>
>

Received on Saturday, 23 March 2013 12:35:31 UTC