W3C home > Mailing lists > Public > www-forms@w3.org > December 2006

Re: XPath based context and filtering for submission?

From: Jason <jeacott@hardlight.com.au>
Date: Fri, 01 Dec 2006 10:55:39 +1030
Message-ID: <456F7683.1040202@hardlight.com.au>
To: "Klotz, Leigh" <Leigh.Klotz@xerox.com>
CC: www-forms <www-forms@w3.org>

I think allowing an xslt or other arbitrary language filter is a much 
better option. xpath alone will never get you a formatted, human 
readable email message for example. I know it violates the declarative 
thing, but not all processing lends itself well to the declarative model.

Jason.

Klotz, Leigh wrote:
> Itwouldbeniceif there were a way to filter a list of matching nodes to
> submit.
> 
> I would like to submit only the index numbers of items whose @selected
> attribute is true.
> 
> The present definition of submission/@ref uses the first nodeset rule,
> so you cannot just do
>   <submission
> ref="instance('data')/lines/line[boolean-from-string(@selected)]/index"
> />
> Additionally, the ref attribute doesn't appear to be precise enough to
> specify what parts of the tree to submit and what parts to leave out.
> 
> Some simple XPath-based filtering syntax like that would be attractive,
> though.
> 
> Here's one way to do it, using a control variable (set during submission
> only) and a pair of bind elements, one to say the
> "/lines/line[boolean-from-string(@selected)]" part and another to say
> that "index" part. 
> 
> Can anybody think of a clever union expression to put in submission/@ref
> that just does what I want?
> 
> <instance id="data">
>   <data xmlns="">
>     <lines>
>       <line selected="false">
>         <index>1</index>
>         <date>2006-01-01T00:00:00Z</date>
>         <name>A</name>
>         <text>...</text>
>       </line>
>       <line selected="false">
>         <index>2</index>
>         <date>2006-01-01T01:00:00Z</date>
>         <name>B</name>
>         <text>...</text>
>       </line>
>       <line selected="false">
>         <index>3</index>
>         <date>2006-01-01T02:00:00Z</date>
>         <name>C</name>
>         <text>...</text>
>       </line>
>      </lines>
>   </data>
> </instance>
> 
> <instance id="results">
>   <empty xmlns=""/>
> </instance>
> 
> <instance id="control">
>   <control xmlns="">
>     <selected>false</selected>
>   </control>
> </instance>
> 
> <bind nodeset="instance('data')lines/line/@selected" type="xsd:boolean"
> />
> <bind nodeset="instance('control')/selected" type="xsd:boolean" />
> 
> <bind nodeset="instance('data')/lines/*[local-name(.)!='index']" 
>       relevant="not(boolean-from-string(instance('control')/selected))
> <bind nodeset="instance('data')/lines/line"
> 	relevant="not(boolean-from-string(instance('control')/selected))
> or boolean-from-string(@selected)"/>
> 
> <submission id="delete" action="/delete" ref="instance('data')"
> replace="instance" instance="results">
>    <setvalue ev:event="xforms-submit"
> ref="instance('control')/selected">true</setvalue>
>    <setvalue ev:event="xforms-submit-done"
> ref="instance('control')/selected">false</setvalue>
>    <setvalue ev:event="xforms-submit-error"
> ref="instance('control')/selected">false</setvalue>
> </submission>
> 
> <submit submission="delete">
>   <label>Delete</label>
> </submit>
> 
> <repeat id="lines" nodeset="lines/line">
>   <input ref="@selected">
>     <label class="columnHeader">X</label>
>   </input>
>   <output ref="date">
>     <label class="columnHeader">Date</label>
>   </output>
>   <output ref="name">
>     <label class="columnHeader">Name</label>
>   </output>
> </repeat>
> 
> <output ref="lines/line[index('lines')]/text">
>   <label>Text</label>
> </output>
> 
> 
> 
Received on Friday, 1 December 2006 00:25:56 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 10 March 2012 06:22:08 GMT