- From: Norman Walsh <ndw@nwalsh.com>
- Date: Thu, 28 May 2009 08:42:06 -0400
- To: XProc Dev <xproc-dev@w3.org>
- Message-ID: <m2y6shbdr5.fsf@nwalsh.com>
"Toman_Vojtech@emc.com" <Toman_Vojtech@emc.com> writes:
>> A small win, but a win !
[...]
> With choose, you don't have this problem.
True. Here, FWIW, is what the pipeline looks like if we add a
p:option-available function that takes a single QName and returns true
if and only if an option with that name exists and has a value.
<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:choose>
<p:xpath-context>
<p:empty/>
</p:xpath-context>
<p:when test="p:option-available('include-filter')
and p:option-available('exclude-filter')">
<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:when>
<p:when test="p:option-available('exclude-filter')">
<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:when>
<p:when test="p:option-available('include-filter')">
<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:when>
<p:otherwise>
<p:directory-list>
<p:with-option name="path" select="$path">
<p:empty/>
</p:with-option>
</p:directory-list>
</p:otherwise>
</p:choose>
<p:viewport match="c:directory[parent::*]">
<p:choose>
<p:when test="$depth != 0 and p:option-available('include-filter')
and p:option-available('exclude-filter')">
<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:when>
<p:when test="$depth != 0 and p:option-available('exclude-filter')">
<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:when>
<p:when test="$depth != 0 and p:option-available('include-filter')">
<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:when>
<p:when test="$depth != 0">
<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:when>
<p:otherwise>
<p:identity/>
</p:otherwise>
</p:choose>
</p:viewport>
</p:declare-step>
Be seeing you,
norm
--
Norman Walsh <ndw@nwalsh.com> | Talk as if you were making your will:
http://nwalsh.com/ | the fewer the words the less the
| litigation.-- Gracián
Received on Thursday, 28 May 2009 12:42:49 UTC