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 Wednesday, 27 May 2009 23:43:14 UTC