nested repeats & trigger to insert/delete nested repeat = problem

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

nested repeats & trigger to insert/delete nested repeat = problem

Tanya Gray (Oxford)
Hi, I am using OPS to auto-generate input forms from an XML schema, e.g.
http://gensc.org/gencat/gcat/reports/create/input?file=schema-version8.xsd&version=8

The input form must support nested repeats, with triggers to insert/remove repeats. Code excerpt for an insert trigger:

<xforms:trigger
                  appearance="xxforms:image"
                    ref="instance('triggers')//add-{@id}">
                    <xforms:label>Add</xforms:label>
                    <xxforms:img src="/gcat/images/add.gif"/>
                    <xforms:insert nodeset="instance('main-instance')/{saxon:path()}"
                        ev:event="DOMActivate" at="1" position="before"/>
</xforms:trigger>

This works fine  **except** when there are nested repeats, e.g.

* element-type-1
   ** element-type-2
* element-type-1
   ** element-type-2
   ** element-type-2

In this example, when a trigger is used to insert an element of element-type-2, it will be inserted  as a child of the first element-type-1.  

* element-type-1
   ** inserted here **
   ** element-type-2
* element-type-1
   ** element-type-2
   ** element-type-2
   ** want to insert here **

The problem is how to insert a nested repeat in the correct place. I think the repeat index value is the way to achieve the desired effect i.e. insert a new element-type-2 directly before/after the selected element. However, the value of  the repeat index ( index('repeat-id') ) is equal to 1 when the trigger is activated. Perhaps this is because the trigger references an element in a different instance, to the main input form?

If someone is able to offer insight into how to achieve the desired effect, I would be very happy :-)

thanks v much
Tanya

 









--
This message (and any attachments) is for the recipient only. NERC
is subject to the Freedom of Information Act 2000 and the contents
of this email and any reply you make may be disclosed by NERC unless
it is exempt from release under the Act. Any material supplied to
NERC may be stored in an electronic records management system.



--
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: nested repeats & trigger to insert/delete nested repeat = problem

ilango_g
Hi

The inner repeat's index always starts from 1. Hence, after a new empty section of elements is created and becomes current, the first insert element operation adds the newly created element at the front of the list.

For example consider the following repeat structure:

<xforms:repeat id="element-type1-repeat" nodeset="instance('in-stock')/groceries/frozen/item">
    <xforms:output ref="@type">
        <xforms:label>Item type: </xforms:label>
    </xforms:output>
    <xforms:repeat id="element-type1-repeat" nodeset="info">
        <xforms:output ref="@brand">
            <xforms:label>Brand: </xforms:label>
        </xforms:output>
        <xforms:input ref="@quantity">
            <xforms:label>Quantity: </xforms:label>
        </xforms:input>
    </xforms:repeat>
    <xhtml:hr/>
</xforms:repeat>

Note the position of the new inner repeat. This example defines an output within the outermost repeat, for which each item type is displayed. Then, an inner repeat iterates over the info elements within each item. Notice that the XPath in the inner repeat's nodeset attribute is defined relative to the nodeset of its containing repeat.

I hope I have been helpful to some extent at least.




Tanya Gray (Oxford) wrote
Hi, I am using OPS to auto-generate input forms from an XML schema, e.g.
http://gensc.org/gencat/gcat/reports/create/input?file=schema-version8.xsd&version=8

The input form must support nested repeats, with triggers to insert/remove repeats. Code excerpt for an insert trigger:

<xforms:trigger
                  appearance="xxforms:image"
                    ref="instance('triggers')//add-{@id}">
                    <xforms:label>Add</xforms:label>
                    <xxforms:img src="/gcat/images/add.gif"/>
                    <xforms:insert nodeset="instance('main-instance')/{saxon:path()}"
                        ev:event="DOMActivate" at="1" position="before"/>
</xforms:trigger>

This works fine  **except** when there are nested repeats, e.g.

* element-type-1
   ** element-type-2
* element-type-1
   ** element-type-2
   ** element-type-2

In this example, when a trigger is used to insert an element of element-type-2, it will be inserted  as a child of the first element-type-1.  

* element-type-1
   ** inserted here **
   ** element-type-2
* element-type-1
   ** element-type-2
   ** element-type-2
   ** want to insert here **

The problem is how to insert a nested repeat in the correct place. I think the repeat index value is the way to achieve the desired effect i.e. insert a new element-type-2 directly before/after the selected element. However, the value of  the repeat index ( index('repeat-id') ) is equal to 1 when the trigger is activated. Perhaps this is because the trigger references an element in a different instance, to the main input form?

If someone is able to offer insight into how to achieve the desired effect, I would be very happy :-)

thanks v much
Tanya

 









--
This message (and any attachments) is for the recipient only. NERC
is subject to the Freedom of Information Act 2000 and the contents
of this email and any reply you make may be disclosed by NERC unless
it is exempt from release under the Act. Any material supplied to
NERC may be stored in an electronic records management system.



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

Re: Re: nested repeats & trigger to insert/delete nested repeat = problem

Tanya Gray (Oxford)
In reply to this post by Tanya Gray (Oxford)
Hi

I see in the example a relative nodeset reference allows for nested repeats to be inserted correctly.

The problem I encountered was that the trigger I used to control repeats, referenced another instance. This meant that it was necessary to provide a full path to the repeat nodeset, and resulted in repeats being inserted in the wrong location.

It seems the only solution is for the trigger reference to be removed, although this means that it is not possible to control the trigger behaviour.

thank you for your help
Tanya



>>> [hidden email] 03/21/08 1:37 PM >>>

Hi

The inner repeat's index always starts from 1. Hence, after a new empty
section of elements is created and becomes current, the first insert element
operation adds the newly created element at the front of the list.

For example consider the following repeat structure:

<xforms:repeat id="element-type1-repeat"
nodeset="instance('in-stock')/groceries/frozen/item">
    <xforms:output ref="@type">
        <xforms:label>Item type: </xforms:label>
    </xforms:output>
    <xforms:repeat id="element-type1-repeat" nodeset="info">
        <xforms:output ref="@brand">
            <xforms:label>Brand: </xforms:label>
        </xforms:output>
        <xforms:input ref="@quantity">
            <xforms:label>Quantity: </xforms:label>
        </xforms:input>
    </xforms:repeat>
    <xhtml:hr/>
</xforms:repeat>

Note the position of the new inner repeat. This example defines an output
within the outermost repeat, for which each item type is displayed. Then, an
inner repeat iterates over the info elements within each item. Notice that
the XPath in the inner repeat's nodeset attribute is defined relative to the
nodeset of its containing repeat.

I hope I have been helpful to some extent at least.





Tanya Gray (Oxford) wrote:

>
> Hi, I am using OPS to auto-generate input forms from an XML schema, e.g.
> http://gensc.org/gencat/gcat/reports/create/input?file=schema-version8.xsd&version=8
>
> The input form must support nested repeats, with triggers to insert/remove
> repeats. Code excerpt for an insert trigger:
>
> <xforms:trigger
>                   appearance="xxforms:image"
>                     ref="instance('triggers')//add-{@id}">
>                     <xforms:label>Add</xforms:label>
>                     <xxforms:img src="/gcat/images/add.gif"/>
>                     <xforms:insert
> nodeset="instance('main-instance')/{saxon:path()}"
>                         ev:event="DOMActivate" at="1" position="before"/>
> </xforms:trigger>
>
> This works fine  **except** when there are nested repeats, e.g.
>
> * element-type-1
>    ** element-type-2
> * element-type-1
>    ** element-type-2
>    ** element-type-2
>
> In this example, when a trigger is used to insert an element of
> element-type-2, it will be inserted  as a child of the first
> element-type-1.  
>
> * element-type-1
>    ** inserted here **
>    ** element-type-2
> * element-type-1
>    ** element-type-2
>    ** element-type-2
>    ** want to insert here **
>
> The problem is how to insert a nested repeat in the correct place. I think
> the repeat index value is the way to achieve the desired effect i.e.
> insert a new element-type-2 directly before/after the selected element.
> However, the value of  the repeat index ( index('repeat-id') ) is equal to
> 1 when the trigger is activated. Perhaps this is because the trigger
> references an element in a different instance, to the main input form?
>
> If someone is able to offer insight into how to achieve the desired
> effect, I would be very happy :-)
>
> thanks v much
> Tanya
>
>  
>
>
>
>
>
>
>
>
>
> --
> This message (and any attachments) is for the recipient only. NERC
> is subject to the Freedom of Information Act 2000 and the contents
> of this email and any reply you make may be disclosed by NERC unless
> it is exempt from release under the Act. Any material supplied to
> NERC may be stored in an electronic records management system.
>
>
>
> --
> 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
>
>
--
View this message in context: http://www.nabble.com/nested-repeats---trigger-to-insert-delete-nested-repeat-%3D-problem-tp16182750p16197924.html
Sent from the ObjectWeb OPS - Users mailing list archive at Nabble.com.



--
This message (and any attachments) is for the recipient only. NERC
is subject to the Freedom of Information Act 2000 and the contents
of this email and any reply you make may be disclosed by NERC unless
it is exempt from release under the Act. Any material supplied to
NERC may be stored in an electronic records management system.



--
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: nested repeats & trigger to insert/delete nested repeat = problem

Alessandro Vernet
Administrator
On Mar 26, 2008, at 3:30 AM, Tanya Gray (Oxford) wrote:
> It seems the only solution is for the trigger reference to be  
> removed, although this means that it is not possible to control the  
> trigger behaviour.


If you are using a recent nightly build, the XForms 1.1 context()  
function or <xxforms:variable> should help out here.

Alex
--
Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise
Orbeon's Blog: http://www.orbeon.com/blog/
Personal Blog: http://avernet.blogspot.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