Howto switch two elements in a repeat

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

Howto switch two elements in a repeat

MAILLERE Alban
Hello all,

I'm trying to switch the position of two elements in a simple list...
Let's say I want the 3rd to become the 4th, and respectively.
With the ignored @at on the insert (anybody knows why?) it seems quite impossible...

Lets say my instance is:
<page>
   <list>
        <item>
                ...
        <item>
   </list>
   <list>
        ...
 And so on

In my repeat matching "list" I have something like :
<xforms:insert nodeset="item[5]" at="4" position="before" ev:event="DOMActivate"/>

It will just double item 5 to 5 and 6

Just in case it matters, I'm in a "separate context"
Many thanks in advance, any help will be much appreciated.


Regards,

Alban MAILLERE
02-23-20-91-14
-------------------------------------
MICROPOLE-UNIVERS
Immeuble Les Galaxies, 3, square René Cassin
35700 Rennes

Email : [hidden email]
Fax : + 33.2.23.20.11.12
http://www.micropole-univers.com
------------------------------------




--
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: Howto switch two elements in a repeat

Jeroen Hoffman

Isn't the @nodeset supposed to be pointing at the collection of all items
instead of just the fifth? In other words, did you try nodeset="item"?

Besides that, you probably need do to an xforms:delete too as an xforms:insert
will always create a new element.

Jeroen


MAILLERE Alban wrote:

> Hello all,
>
> I'm trying to switch the position of two elements in a simple list...
> Let's say I want the 3rd to become the 4th, and respectively.
> With the ignored @at on the insert (anybody knows why?) it seems quite impossible...
>
> Lets say my instance is:
> <page>
>    <list>
> <item>
> ...
> <item>
>    </list>
>    <list>
> ...
>  And so on
>
> In my repeat matching "list" I have something like :
> <xforms:insert nodeset="item[5]" at="4" position="before" ev:event="DOMActivate"/>
>
> It will just double item 5 to 5 and 6
>
> Just in case it matters, I'm in a "separate context"
> Many thanks in advance, any help will be much appreciated.
>
>
> Regards,
>
> Alban MAILLERE
> 02-23-20-91-14
> -------------------------------------
> MICROPOLE-UNIVERS
> Immeuble Les Galaxies, 3, square René Cassin
> 35700 Rennes
>
> Email : [hidden email]
> Fax : + 33.2.23.20.11.12
> http://www.micropole-univers.com
> ------------------------------------
>
>
>


--
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: Howto switch two elements in a repeat

MAILLERE Alban
Sure jeroen, i'll delete an item after the insert for the switch ... I'm just trying to insert at the right position for now (shouldn't it be easy?...)
For the @nodeset, the least I can say is that its behaviour isn't obvious. Ops doesn't seem to manage it the "usual" way as long as the @at is ignored.
I am only wondering how I can insert an item from a liste at any index I want in this list.
Any method I tried only allowed me to insert this item before or after itself...



-----Message d'origine-----
De : Jeroen Hoffman [mailto:[hidden email]]
Envoyé : vendredi 30 janvier 2009 10:41
À : [hidden email]
Objet : [ops-users] Re: Howto switch two elements in a repeat


Isn't the @nodeset supposed to be pointing at the collection of all items
instead of just the fifth? In other words, did you try nodeset="item"?

Besides that, you probably need do to an xforms:delete too as an xforms:insert
will always create a new element.

Jeroen


MAILLERE Alban wrote:

> Hello all,
>
> I'm trying to switch the position of two elements in a simple list...
> Let's say I want the 3rd to become the 4th, and respectively.
> With the ignored @at on the insert (anybody knows why?) it seems quite impossible...
>
> Lets say my instance is:
> <page>
>    <list>
> <item>
> ...
> <item>
>    </list>
>    <list>
> ...
>  And so on
>
> In my repeat matching "list" I have something like :
> <xforms:insert nodeset="item[5]" at="4" position="before" ev:event="DOMActivate"/>
>
> It will just double item 5 to 5 and 6
>
> Just in case it matters, I'm in a "separate context"
> Many thanks in advance, any help will be much appreciated.
>
>
> Regards,
>
> Alban MAILLERE
> 02-23-20-91-14
> -------------------------------------
> MICROPOLE-UNIVERS
> Immeuble Les Galaxies, 3, square René Cassin
> 35700 Rennes
>
> Email : [hidden email]
> Fax : + 33.2.23.20.11.12
> http://www.micropole-univers.com
> ------------------------------------
>
>
>


--
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: Re: Howto switch two elements in a repeat

Jeroen Hoffman
Hi,
I think using the XPath number() function in the @at will work, which will
convert the string 4 into a XPath type number type.

Jeroen

MAILLERE Alban wrote:

> Sure jeroen, i'll delete an item after the insert for the switch ... I'm just trying to insert at the right position for now (shouldn't it be easy?...)
> For the @nodeset, the least I can say is that its behaviour isn't obvious. Ops doesn't seem to manage it the "usual" way as long as the @at is ignored.
> I am only wondering how I can insert an item from a liste at any index I want in this list.
> Any method I tried only allowed me to insert this item before or after itself...
>
>
>
> -----Message d'origine-----
> De : Jeroen Hoffman [mailto:[hidden email]]
> Envoyé : vendredi 30 janvier 2009 10:41
> À : [hidden email]
> Objet : [ops-users] Re: Howto switch two elements in a repeat
>
>
> Isn't the @nodeset supposed to be pointing at the collection of all items
> instead of just the fifth? In other words, did you try nodeset="item"?
>
> Besides that, you probably need do to an xforms:delete too as an xforms:insert
> will always create a new element.
>
> Jeroen
>
>
> MAILLERE Alban wrote:
>> Hello all,
>>
>> I'm trying to switch the position of two elements in a simple list...
>> Let's say I want the 3rd to become the 4th, and respectively.
>> With the ignored @at on the insert (anybody knows why?) it seems quite impossible...
>>
>> Lets say my instance is:
>> <page>
>>    <list>
>> <item>
>> ...
>> <item>
>>    </list>
>>    <list>
>> ...
>>  And so on
>>
>> In my repeat matching "list" I have something like :
>> <xforms:insert nodeset="item[5]" at="4" position="before" ev:event="DOMActivate"/>
>>
>> It will just double item 5 to 5 and 6
>>
>> Just in case it matters, I'm in a "separate context"
>> Many thanks in advance, any help will be much appreciated.
>>
>>
>> Regards,
>>
>> Alban MAILLERE
>> 02-23-20-91-14
>> -------------------------------------
>> MICROPOLE-UNIVERS
>> Immeuble Les Galaxies, 3, square René Cassin
>> 35700 Rennes
>>
>> Email : [hidden email]
>> Fax : + 33.2.23.20.11.12
>> http://www.micropole-univers.com
>> ------------------------------------
>>
>>
>>


--
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: Howto switch two elements in a repeat

Erik Bruchez
Administrator
In reply to this post by MAILLERE Alban
> I'm trying to switch the position of two elements in a simple list...
> Let's say I want the 3rd to become the 4th, and respectively.
> With the ignored @at on the insert (anybody knows why?) it seems  
> quite impossible...

@at is not ignored.

> Lets say my instance is:
> <page>
>   <list>
> <item>
> ...
> <item>
>   </list>
>   <list>
> ...
> And so on
>
> In my repeat matching "list" I have something like :
> <xforms:insert nodeset="item[5]" at="4" position="before"  
> ev:event="DOMActivate"/>
@at is the position within the node-set pointed to by @nodeset. In  
your example, the node-set contains only one element, so its size is  
1. There is no 4th position in a node-set of only one element. As  
suggested, you need @nodeset="list".

> It will just double item 5 to 5 and 6

Which is the expected behavior.

-Erik

--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/



--
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: Howto switch two elements in a repeat

MAILLERE Alban
Ok it worked this way ... Many thanks Erik and Jeroen for the great explanations
I just mislead myself using nodeset="." (my list tag) instead of "./*" (my actual list of items)

Regards,
Alban

-----Message d'origine-----
De : Erik Bruchez [mailto:[hidden email]]
Envoyé : vendredi 30 janvier 2009 20:55
À : [hidden email]
Objet : [ops-users] Re: Howto switch two elements in a repeat

> I'm trying to switch the position of two elements in a simple list...
> Let's say I want the 3rd to become the 4th, and respectively.
> With the ignored @at on the insert (anybody knows why?) it seems  
> quite impossible...

@at is not ignored.

> Lets say my instance is:
> <page>
>   <list>
> <item>
> ...
> <item>
>   </list>
>   <list>
> ...
> And so on
>
> In my repeat matching "list" I have something like :
> <xforms:insert nodeset="item[5]" at="4" position="before"  
> ev:event="DOMActivate"/>
@at is the position within the node-set pointed to by @nodeset. In  
your example, the node-set contains only one element, so its size is  
1. There is no 4th position in a node-set of only one element. As  
suggested, you need @nodeset="list".

> It will just double item 5 to 5 and 6

Which is the expected behavior.

-Erik

--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/



--
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