Re: Variables and parameters

/ Alessandro Vernet <avernet@orbeon.com> was heard to say:
| <p:pipeline xmlns:p="http://www.w3.org/2006/XProc/Pipeline">
|
|       <p:input name="request"/>
|       <p:output name="response" select="$result"/>
|
|       <p:variable name="has-namespaces"
|               select="count(/*/namespace::*) > 0"/>
|
|       <p:step name="validate">
|               <p:with-input name="schema" href="my-schema.xsd"/>
|               <p:with-input name="document" select="$request"/>
|               <p:with-param name="do-namespace-processing"
|                       select="$has-namespaces"/>
|               <p:with-output name="name" label="validity"/>
|       </p:step>
|
|       <p:choose>
|               <p:when test="$validity = 'true'">
|                       <p:step name="process-request">
|                               <p:with-input name="document" select="$request"/>
|                               <p:with-output name="result" label="result"/>
|                       </p:step>
|               </p:when>
|               <p:otherwise>
|                       <p:step name="return-error">
|                               <p:with-output name="error" label="result"/>
|                       </p:step>
|               </p:otherwise>
|       </p:choose>
|
| </p:pipeline>

I've been expecting p:if/p:choose/p:pipeline/p:for-each/etc. to be
self-contained. As you've written it here, the p:when branch "reaches
out" of the p:choose to get the request. I think that makes it harder
to analyze the conditional, but maybe I'm mistaken.

I expected something like this:

  <p:choose>
    <p:param name="isvalid" select="$validity"/>
    <p:input name="document" select="$request"/>
    <p:output name="result"/>

    <p:when test="$isvalid = 'true'">
      <p:step name="process-request">
        <p:with-input name="document" select="$document"/>
        <p:with-output name="result" ref="result"/>
      </p:step>
    </p:when>
    <p:otherwise>
      <p:step name="return-error">
        <p:with-output name="error" ref="result"/>
      </p:step>
    </p:otherwise>

  </p:choose>

That way, it's an error for the steps inside one of these "wrapper"
components to reach outside. I'm also pointing from the with-output
statement to the p:output rather than the other way around. I'm not
sure about that.

I'm also not sure how much effort is required to make sure that
'result' is defined in every branch...

                                        Be seeing you,
                                          norm

-- 
Norman Walsh
XML Standards Architect
Sun Microsystems, Inc.

Received on Wednesday, 24 May 2006 14:55:31 UTC