RE: Detecting unbound options

Beautiful.

Just a note about this:

>> Alas, I think that would just trade a great big nested p:try/p:catch
>> for a great big p:choose...
>
> A small win, but a win !

I think that it's not that small win, actually. The problem with
try/catch is that the catch sub-pipeline is invoked whenever *anything*
goes wrong, not just when some of the options are unbound. If, for
instance, the directory-list simply fails to read the contents of the
directory, the catch will run a second directory-list, which fails, too,
and so on. Of course, you can check the error code in your catch
sub-pipeline to detect what really went wrong, but that would be a)
unreliable, and b) it would make the pipelines even more horrible.

With choose, you don't have this problem.

Regards,
Vojtech


> -----Original Message-----
> From: xproc-dev-request@w3.org 
> [mailto:xproc-dev-request@w3.org] On Behalf Of Norman Walsh
> Sent: Thursday, May 28, 2009 1:43 AM
> To: XProc Dev
> Subject: Re: Detecting unbound options
> 
> > Yuck! But can we really live with this...
> 
> Here, for the record, is a a recursive-directory-list step.
> 
> <p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
>                 xmlns:c="http://www.w3.org/ns/xproc-step"
>                 xmlns:pxp="http://exproc.org/proposed/steps"
>                 type="pxp:recursive-directory-list">
> <p:output port="result"/>
> <p:option name="path" required="true"/>
> <p:option name="depth" select="0"/>
> <p:option name="include-filter"/>
> <p:option name="exclude-filter"/>
> 
> <p:try>
>   <p:group>
>     <p:directory-list>
>       <p:with-option name="path" select="$path">
>         <p:empty/>
>       </p:with-option>
>       <p:with-option name="include-filter" select="$include-filter">
>         <p:empty/>
>       </p:with-option>
>       <p:with-option name="exclude-filter" select="$exclude-filter">
>         <p:empty/>
>       </p:with-option>
>     </p:directory-list>
>   </p:group>
>   <p:catch>
>     <p:try>
>       <p:group>
>         <p:directory-list>
>           <p:with-option name="path" select="$path">
>             <p:empty/>
>           </p:with-option>
>           <p:with-option name="exclude-filter" 
> select="$exclude-filter">
>             <p:empty/>
>           </p:with-option>
>         </p:directory-list>
>       </p:group>
>       <p:catch>
>         <p:try>
>           <p:group>
>             <p:directory-list>
>               <p:with-option name="path" select="$path">
>                 <p:empty/>
>               </p:with-option>
>               <p:with-option name="include-filter" 
> select="$include-filter">
>                 <p:empty/>
>               </p:with-option>
>             </p:directory-list>
>           </p:group>
>           <p:catch>
>             <p:directory-list>
>               <p:with-option name="path" select="$path">
>                 <p:empty/>
>               </p:with-option>
>             </p:directory-list>
>           </p:catch>
>         </p:try>
>       </p:catch>
>     </p:try>
>   </p:catch>
> </p:try>
> 
> <p:viewport match="c:directory[parent::*]">
>   <p:choose>
>     <p:when test="$depth != 0">
>       <p:try>
>         <p:group>
> 	  <pxp:recursive-directory-list>
>             <p:with-option name="path" 
> select="concat($path,'/',/c:directory/@name)"/>
> 	    <p:with-option name="depth" select="$depth - 1">
> 	      <p:empty/>
> 	    </p:with-option>
>             <p:with-option name="include-filter" 
> select="$include-filter">
>               <p:empty/>
>             </p:with-option>
>             <p:with-option name="exclude-filter" 
> select="$exclude-filter">
>               <p:empty/>
>             </p:with-option>
> 	  </pxp:recursive-directory-list>
>         </p:group>
>         <p:catch>
>           <p:try>
> 	    <p:group>
> 	      <pxp:recursive-directory-list>
> 		<p:with-option name="path" 
> select="concat($path,'/',/c:directory/@name)"/>
> 		<p:with-option name="depth" select="$depth - 1">
> 		  <p:empty/>
> 		</p:with-option>
> 		<p:with-option name="exclude-filter" 
> select="$exclude-filter">
> 		  <p:empty/>
>                 </p:with-option>
> 	      </pxp:recursive-directory-list>
>             </p:group>
>             <p:catch>
>               <p:try>
>                 <p:group>
> 		  <pxp:recursive-directory-list>
> 		    <p:with-option name="path" 
> select="concat($path,'/',/c:directory/@name)"/>
> 		    <p:with-option name="depth" select="$depth - 1">
> 		      <p:empty/>
> 		    </p:with-option>
> 		    <p:with-option name="include-filter" 
> select="$include-filter">
> 		      <p:empty/>
>                     </p:with-option>
> 		  </pxp:recursive-directory-list>
>                 </p:group>
>                 <p:catch>
> 		  <pxp:recursive-directory-list>
> 		    <p:with-option name="path" 
> select="concat($path,'/',/c:directory/@name)"/>
> 		    <p:with-option name="depth" select="$depth - 1">
> 		      <p:empty/>
> 		    </p:with-option>
> 		  </pxp:recursive-directory-list>
>                 </p:catch>
>               </p:try>
>             </p:catch>
>           </p:try>
>         </p:catch>
>       </p:try>
>     </p:when>
>     <p:otherwise>
>       <p:identity/>
>     </p:otherwise>
>   </p:choose>
> </p:viewport>
> 
> </p:declare-step>
> 
>                                         Be seeing you,
>                                           norm
> 
> -- 
> Norman Walsh <ndw@nwalsh.com> | We are at the very beginning of time
> http://nwalsh.com/            | for the human race. It is not
>                               | unreasonable that we grapple with
>                               | problems. But there are tens of
>                               | thousands of years in the future. Our
>                               | responsibility is to do what we can,
>                               | learn what we can, improve the
>                               | solutions, and pass them on.--Richard
>                               | Feynman
> 

Received on Thursday, 28 May 2009 07:30:48 UTC