Re: Detecting unbound options

Norm,


On Wed, May 27, 2009 at 4:06 PM, Norman Walsh <ndw@nwalsh.com> wrote:
> "Henry S. Thompson" <ht@inf.ed.ac.uk> writes:
>>> Yuck! But can we really live with this...
>>
>> For sure not.
>>
>> The most straightforward approach would be to add p:bound? as an XPath
>> extension function.
>
> 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 !

Let's try to solve your use case

Here are the ways to solve it with the lesser code
1) First, is to say that selecting an unbound variable will generate
un unbound variable (a bit tricky)
2) To add an attribute on p:with-option that says
@bound-like-this-option="$foo" ; if foo is bound then the variable
will be bound and the value will be the content of the select and will
not be bound if $foo isn't bound

In this case you just have to write


<p:directory-list>
 <p:with-option name="path" select="$path" bound-like-this-option="$path">
   <p:empty/>
 </p:with-option>
 <p:with-option name="include-filter" select="$include-filter"
bound-like-this-option="$include-filter">
   <p:empty/>
 </p:with-option>
 <p:with-option name="exclude-filter" select="$exclude-filter"
bound-like-this-option="$exclude-filter">
   <p:empty/>
 </p:with-option>
</p:directory-list>

We eventually need to come up with a better name for this attribute

Xmlizer

Received on Wednesday, 27 May 2009 16:50:07 UTC