Filter data when insert

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Filter data when insert

islegmar
Hi

This is more a "pure" XForm question than an Orbeon one, but I'm sure you experts can help me :-) otherwise I would appreciate a hint about where can I ask it.

For inserting optional data in my XForm I have instance called 'template' where I have all possible data (if we forget about the 'choice' case, it is a XML with all the optional data). When I click insert, I copy the corresponding node form 'template' into 'instance'. This is working fine. My question is, how can I filter the data that is copied? So, in certain circumstances I don't want to copy the entire node, I want to skip some children node (based on a certain XPath expression), how can I do it?

For example my 'template' data looks like

<person>
  <address>   ----> Optional Data
    <name/>
    <number/>
  </address>
  <age>
</person>

Let's suppose I have an instance data as

<person>
  <age>89</age>
</person>

In my XForm I have a button 'Add Address'. If I click on it, I copy the following node from 'template' into 'instance'

<address>
  <name/>
  <number/>
</address>

so my instance data looks like

<person>
  <address>  ----> Node added
    <name/>
    <number/>
  </address>
  <age>89</age>
</person>

For that I execute a code like (not checked)

<xf:insert position="after" at="last()" context="." ev:event="DOMActivate" nodeset="..." origin="instance('template')/person/address"/>

My question is, can I skip for example to copy the node <number/>? So, I would like to copy

<address>
  <name/>
</address>

and my instance data would look like

<person>
  <address>  ----> Node added without 'number'
    <name/>
  </address>
  <age>89</age>
</person>

For adding number I will show another button and so on.

How can I do it?

I would need some kind of 'generic' solution, no only for this special case.

Thanks a lot

Isi

--
Isidoro Legido Martínez
Senior Software Consultant & Movie Script Writer





--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Filter data when insert

islegmar
Hi

Probably I didn't explain myself very well in my last message :-)

So, let's suppose my 'template' data is something like:

<person>
  <age/>
  <address isi:opt="true">
    <street>
      <name/>
      <number isi:opt="true">
        <cipher/>
        <letter isi:opt="true"/>
      </number>
    </street>
    <city opt="true"/>
  </address>
</person>

where 'isi' is a namespace I use for adding some metadata (so, I shouldn't be posted at the end).
That 'construction' means: address is optional, if you create one, city is optional and number in street is optional, and so on...

My initial instance data looks like

<person>
  <age>88</age>
</person>

and the XForms looks like

Person
  age : 88      -> Input text with the age
  [Add address] -> Button for adding the optional field 'address'

Now, if I press the 'Add address' button I want to add the address node without all the non optional fields
So, I want to select from 'template' the following node:


<address isi:opt="true">
  <street>
    <name/>
    <number isi:opt="true"> ---> Removed
      <cipher/>
      <letter isi:opt="true"/>
    </number>
  </street>
  <city opt="true"/>  --> Removed
</address>

that means:

<address isi:opt="true">
  <street>
    <name/>
  </street>
</address>

After adding it, my instance data would look like: 

<person>
  <age>88</age>
  <address isi:opt="true">
    <street>
      <name/>
    </street>
  </address>
</person>

and the XForm would be

Person
  age : 88
  address
    street
      name : ________
      [Add number]
    [Add city]

Is that possible? When I perform the 'insert' action, can I 'filter' the origin node and remove the children node with the @isi:opt='true'?

I guess this is a XPath question and probably can not be done :-( 

Thanks a lot

Isi 


  

2012/3/29 Isidoro Legido Martínez <[hidden email]>
Hi

This is more a "pure" XForm question than an Orbeon one, but I'm sure you experts can help me :-) otherwise I would appreciate a hint about where can I ask it.

For inserting optional data in my XForm I have instance called 'template' where I have all possible data (if we forget about the 'choice' case, it is a XML with all the optional data). When I click insert, I copy the corresponding node form 'template' into 'instance'. This is working fine. My question is, how can I filter the data that is copied? So, in certain circumstances I don't want to copy the entire node, I want to skip some children node (based on a certain XPath expression), how can I do it?

For example my 'template' data looks like

<person>
  <address>   ----> Optional Data
    <name/>
    <number/>
  </address>
  <age>
</person>

Let's suppose I have an instance data as

<person>
  <age>89</age>
</person>

In my XForm I have a button 'Add Address'. If I click on it, I copy the following node from 'template' into 'instance'

<address>
  <name/>
  <number/>
</address>

so my instance data looks like

<person>
  <address>  ----> Node added
    <name/>
    <number/>
  </address>
  <age>89</age>
</person>

For that I execute a code like (not checked)

<xf:insert position="after" at="last()" context="." ev:event="DOMActivate" nodeset="..." origin="instance('template')/person/address"/>

My question is, can I skip for example to copy the node <number/>? So, I would like to copy

<address>
  <name/>
</address>

and my instance data would look like

<person>
  <address>  ----> Node added without 'number'
    <name/>
  </address>
  <age>89</age>
</person>

For adding number I will show another button and so on.

How can I do it?

I would need some kind of 'generic' solution, no only for this special case.

Thanks a lot

Isi

--
Isidoro Legido Martínez
Senior Software Consultant & Movie Script Writer






--
Isidoro Legido Martínez
Senior Software Consultant & Movie Script Writer





--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Filter data when insert

Erik Bruchez
Administrator
Isi,

It is possible but, xforms:insert doesn't have a filter, so you must
do it in a couple of steps:

- first insert the template
- then delete the nodes you don't want from the destination with xforms:delete

You could also:

- copy the template to another instance
- remove the extra nodes there
- then insert the filtered template in the final destination

For simplicity I would go with the first solution.

-Erik

2012/3/29 Isidoro Legido Martínez <[hidden email]>:

> Hi
>
> Probably I didn't explain myself very well in my last message :-)
>
> So, let's suppose my 'template' data is something like:
>
> <person>
>   <age/>
>   <address isi:opt="true">
>     <street>
>       <name/>
>       <number isi:opt="true">
>         <cipher/>
>         <letter isi:opt="true"/>
>       </number>
>     </street>
>     <city opt="true"/>
>   </address>
> </person>
>
> where 'isi' is a namespace I use for adding some metadata (so, I shouldn't
> be posted at the end).
> That 'construction' means: address is optional, if you create one, city is
> optional and number in street is optional, and so on...
>
> My initial instance data looks like
>
> <person>
>   <age>88</age>
> </person>
>
> and the XForms looks like
>
> Person
>   age : 88      -> Input text with the age
>   [Add address] -> Button for adding the optional field 'address'
>
> Now, if I press the 'Add address' button I want to add the address node
> without all the non optional fields
> So, I want to select from 'template' the following node:
>
>
> <address isi:opt="true">
>   <street>
>     <name/>
>     <number isi:opt="true"> ---> Removed
>       <cipher/>
>       <letter isi:opt="true"/>
>     </number>
>   </street>
>   <city opt="true"/>  --> Removed
> </address>
>
> that means:
>
> <address isi:opt="true">
>   <street>
>     <name/>
>   </street>
> </address>
>
> After adding it, my instance data would look like:
>
> <person>
>   <age>88</age>
>   <address isi:opt="true">
>     <street>
>       <name/>
>     </street>
>   </address>
> </person>
>
> and the XForm would be
>
> Person
>   age : 88
>   address
>     street
>       name : ________
>       [Add number]
>     [Add city]
>
> Is that possible? When I perform the 'insert' action, can I 'filter' the
> origin node and remove the children node with the @isi:opt='true'?
>
> I guess this is a XPath question and probably can not be done :-(
>
> Thanks a lot
>
> Isi
>
>
>
>
> 2012/3/29 Isidoro Legido Martínez <[hidden email]>
>>
>> Hi
>>
>> This is more a "pure" XForm question than an Orbeon one, but I'm sure you
>> experts can help me :-) otherwise I would appreciate a hint about where can
>> I ask it.
>>
>> For inserting optional data in my XForm I have instance called 'template'
>> where I have all possible data (if we forget about the 'choice' case, it is
>> a XML with all the optional data). When I click insert, I copy the
>> corresponding node form 'template' into 'instance'. This is working fine. My
>> question is, how can I filter the data that is copied? So, in certain
>> circumstances I don't want to copy the entire node, I want to skip some
>> children node (based on a certain XPath expression), how can I do it?
>>
>> For example my 'template' data looks like
>>
>> <person>
>>   <address>   ----> Optional Data
>>     <name/>
>>     <number/>
>>   </address>
>>   <age>
>> </person>
>>
>> Let's suppose I have an instance data as
>>
>> <person>
>>   <age>89</age>
>> </person>
>>
>> In my XForm I have a button 'Add Address'. If I click on it, I copy the
>> following node from 'template' into 'instance'
>>
>> <address>
>>   <name/>
>>   <number/>
>> </address>
>>
>> so my instance data looks like
>>
>> <person>
>>   <address>  ----> Node added
>>     <name/>
>>     <number/>
>>   </address>
>>   <age>89</age>
>> </person>
>>
>> For that I execute a code like (not checked)
>>
>> <xf:insert position="after" at="last()" context="." ev:event="DOMActivate"
>> nodeset="..." origin="instance('template')/person/address"/>
>>
>> My question is, can I skip for example to copy the node <number/>? So, I
>> would like to copy
>>
>> <address>
>>   <name/>
>> </address>
>>
>> and my instance data would look like
>>
>> <person>
>>   <address>  ----> Node added without 'number'
>>     <name/>
>>   </address>
>>   <age>89</age>
>> </person>
>>
>> For adding number I will show another button and so on.
>>
>> How can I do it?
>>
>> I would need some kind of 'generic' solution, no only for this special
>> case.
>>
>> Thanks a lot
>>
>> Isi
>>
>> --
>> Isidoro Legido Martínez
>> Senior Software Consultant & Movie Script Writer
>>
>> +info @ http://www.linkedin.com/in/isidorolegido
>>
>>
>
>
>
> --
> Isidoro Legido Martínez
> Senior Software Consultant & Movie Script Writer
>
> +info @ http://www.linkedin.com/in/isidorolegido
>
>
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing
> list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws