Port unreadable from within p:choose

I've been trying to use XProc to branch the processing of documents 
based on their type. I'm having a hard time understanding the scope of 
the step names.

In the first step ("add_id"), I'm adding xml:id's to divs:

<p:viewport match="//*:div" name="add_id">
     <p:add-attribute match="*:div">
         <p:with-option name="attribute-name" select="'xml:id'"/>
         <p:with-option name="attribute-value" select="generate-id(*)"/>
     </p:add-attribute>
</p:viewport>

In the second step, I'm processing the output depending on the document 
type:

<p:choose name="doc_meta">
     <p:when test="$mode = 'A'">
         <p:xslt initial-mode="process_metadata">
             <p:input port="source">
                 <p:pipe port="result" step="add_id"/>
             </p:input>
             <p:input port="stylesheet">
                 <p:document href="A.xsl"/>
             </p:input>
             <p:input port="parameters"><p:empty/></p:input>
         </p:xslt>
     </p:when>
     <p:otherwise>
         <p:xslt initial-mode="process_metadata">
             <p:input port="source">
                 <p:pipe port="result" step="add_id"/>
             </p:input>
             <p:input port="stylesheet">
                 <p:document href="B.xsl"/>
             </p:input>
             <p:input port="parameters"><p:empty/></p:input>
         </p:xslt>
     </p:otherwise>
</p:choose>

I'm using Calabash in Oxygen, and it's complaining: "XE0001: Unreadable 
port: result on doc_meta." The error is not entirely clear to me and the 
`XE0001` code may be misleading 
(http://tests.xproc.org/results/calabash/). I suspect the problem lies 
in the `result` port of the `add_id` step not being in the scope of the 
p:when branch.

What could I be doing wrong? In the XProc documentation, How can one 
make the results of a selected pipe visible to the branches p:choose ?

Received on Monday, 18 March 2024 08:04:11 UTC