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

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

Received on Thursday, 21 February 2013 22:53:40 UTC