W3C home > Mailing lists > Public > public-xml-processing-model-wg@w3.org > March 2006

More thinking about conditionals

From: Norman Walsh <Norman.Walsh@Sun.COM>
Date: Mon, 20 Mar 2006 09:32:51 -0500
To: public-xml-processing-model-wg@w3.org
Message-ID: <877j6p190s.fsf@nwalsh.com>
I've been thinking about conditionals along the lines that Murray and
Henry proposed on the call last week, where the evaluation of the
condition is performed by a step in the pipeline.

We could say that a component, in addition to performing whatever
processing it does, returns either success or failure (or error, but
let's leave errors aside for the moment). Then a conditional
could look something like this:

  <p:param name="status"/>

  <p:if>
    <p:step name="test">
      <p:param name="condition">$status = 'draft'</p:param>
    </p:step>
    <p:then>
      <p:step name="identity">
        <p:input name="document" use="d"/>
        <p:output/>
      </p:step>
    </p:then>
    <p:else>
      <p:call-pipeline name="expandandvalidate">
        <p:input name="schemas" use="s"/>
        <p:input name="document" use="d"/>
        <p:output/>
      </p:call-pipeline>
    </p:else>
  </p:if>

Or one that relied on an XPath over an input document might look like
this:

  <p:if>
    <p:step name="matches">
      <p:input name="document" use="someLabel"/>
      <p:param name="xpath">/db:*</p:param>
    </p:step>
    <p:then>
      <p:step name="xslt">
        <p:input name="document" use="someLabel"/>
	<p:input name="stylesheet" use="docbookStyle"/>
        <p:output/>
      </p:step>
    </p:then>
    <p:else>
      <p:if>
        <p:step name="matches">
          <p:input name="document" use="someLabel"/>
          <p:param name="xpath">/html:*</p:param>
        </p:step>
        <p:then>
          <p:step name="xslt">
            <p:input name="document" use="someLabel"/>
	    <p:input name="stylesheet" use="htmlStyle"/>
            <p:output/>
          </p:step>
        </p:then>
        <p:else>
	  <p:error>What is this?</p:error>
	</p:else>
      </p:if>
    </p:else>
  </p:if>

We appear to lose the idea of a choose/when construct, but we gain the
complete flexibility of allowing any step to be the conditional. I
suppose we could generalize what a step returns from being a simple
success/failure to some scalar value (like process return codes), but
I wonder if that's going too far.

I observe that we could get fully general conditionals with the idea I
originally proposed (where a conditional always evaluates an XPath
over a particular document) simply by writing our conditional
components to return a document:

  <p:step name="myCustomConditional">
    <p:input .../>
    <p:input .../>
    <p:output name="result"/>
  </p:step>

  <p:choose use="result">
    <p:input name="source"/>
    <p:output name="anotherResult"/>

    <p:when test="/someExprOverCustomConditionalResult">
       ...
    </p:when>

    <p:when test="/someOtherExprOverCustomConditionalResult">
       ...
    </p:when>
  </p:choose>

So I'm not sure which approach I prefer at the moment.

                                        Be seeing you,
                                          norm

-- 
Norman.Walsh@Sun.COM / XML Standards Architect / Sun Microsystems, Inc.
NOTICE: This email message is for the sole use of the intended
recipient(s) and may contain confidential and privileged information.
Any unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.

Received on Monday, 20 March 2006 14:33:13 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:21:47 GMT