Cannot insert at index in repeat with multiple element types

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

Cannot insert at index in repeat with multiple element types

FraserHore-2
When inserting an element into a repeat with different element types,
the inserted element always stays with other elements of the same
type.  At index does work if element of type A has the focus and your
are inserting an element of type A.  However if your are inserting an
element of type B, it will be inserted at the end of the first list of
B elements after the A element.  Please see the test case below:

<?xml version="1.0" encoding="UTF-8"?>

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://
www.w3.org/1999/xhtml"
    xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://
www.w3.org/2001/XMLSchema"
    xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:my="http://
www.example.com">

    <head>
        <title>Test</title>
        <xforms:model>
            <xforms:instance id="instanceForm">
                <html xmlns="http://www.w3.org/1999/xhtml"
                    xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:my="http://www.example.com">
                    <head> </head>
                    <body>
                        <my:group>
                            <my:input ref="" id="input1" />
                            <my:input ref="" id="input2" />
                            <my:output ref="" id="output1" />
                            <my:input ref="" id="input3" />
                        </my:group>
                    </body>
                </html>
            </xforms:instance>
            <xforms:instance id="instanceControls">
                <my:group xmlns:xforms="http://www.w3.org/2002/xforms"
                    xmlns:my="http://www.example.com">
                    <my:input ref="Enter Ref" id="Enter ID" />
                    <my:output ref="Enter Ref" id="Enter ID" />
                </my:group>
            </xforms:instance>
        </xforms:model>
        <link href="default.css" rel="stylesheet" />
    </head>

    <body>

        <xforms:group ref="/xhtml:html/xhtml:body/my:group">
            <xforms:label>Controls</xforms:label>
            <xforms:repeat nodeset="*" id="repeatControls">
                <xforms:label>
                    <xforms:output value="substring(name(.), 4)" />
                </xforms:label>
                <xforms:input ref="@ref">
                    <xforms:label>Ref</xforms:label>
                </xforms:input>
                <xforms:input ref="@id">
                    <xforms:label>ID</xforms:label>
                </xforms:input>
            </xforms:repeat>

            <xforms:trigger>
                <xforms:label>Add an Input</xforms:label>
                <xforms:insert context="/xhtml:html/xhtml:body/
my:group" nodeset="my:input"
                    origin="instance('instanceControls')//my:input"
at="index('repeatControls')"
                    position="after" ev:event="DOMActivate" />
            </xforms:trigger>
            <xforms:trigger>
                <xforms:label>Add an Output</xforms:label>
                <xforms:insert context="/xhtml:html/xhtml:body/
my:group" nodeset="my:output"
                    origin="instance('instanceControls')//my:output"
at="index('repeatControls')"
                    position="after" ev:event="DOMActivate" />
            </xforms:trigger>
        </xforms:group>

        <div>
            <strong>Index</strong>
            <xforms:output value="index('repeatControls')" />
        </div>
    </body>
</html>

Is this a problem of approach or a bug?

Thanks!

Frasre

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Cannot insert at index in repeat with multiple element types

FraserHore-2
To put it more simply, you can't add an element of type B between two
elements of type A.


On Sep 14, 4:22 pm, Fraser <[hidden email]> wrote:

> When inserting an element into a repeat with different element types,
> the inserted element always stays with other elements of the same
> type.  At index does work if element of type A has the focus and your
> are inserting an element of type A.  However if your are inserting an
> element of type B, it will be inserted at the end of the first list of
> B elements after the A element.  Please see the test case below:
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml"
>     xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>     xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:my="http://www.example.com">
>
>     <head>
>         <title>Test</title>
>         <xforms:model>
>             <xforms:instance id="instanceForm">
>                 <html xmlns="http://www.w3.org/1999/xhtml"
>                     xmlns:xforms="http://www.w3.org/2002/xforms"
> xmlns:my="http://www.example.com">
>                     <head> </head>
>                     <body>
>                         <my:group>
>                             <my:input ref="" id="input1" />
>                             <my:input ref="" id="input2" />
>                             <my:output ref="" id="output1" />
>                             <my:input ref="" id="input3" />
>                         </my:group>
>                     </body>
>                 </html>
>             </xforms:instance>
>             <xforms:instance id="instanceControls">
>                 <my:group xmlns:xforms="http://www.w3.org/2002/xforms"
>                     xmlns:my="http://www.example.com">
>                     <my:input ref="Enter Ref" id="Enter ID" />
>                     <my:output ref="Enter Ref" id="Enter ID" />
>                 </my:group>
>             </xforms:instance>
>         </xforms:model>
>         <link href="default.css" rel="stylesheet" />
>     </head>
>
>     <body>
>
>         <xforms:group ref="/xhtml:html/xhtml:body/my:group">
>             <xforms:label>Controls</xforms:label>
>             <xforms:repeat nodeset="*" id="repeatControls">
>                 <xforms:label>
>                     <xforms:output value="substring(name(.), 4)" />
>                 </xforms:label>
>                 <xforms:input ref="@ref">
>                     <xforms:label>Ref</xforms:label>
>                 </xforms:input>
>                 <xforms:input ref="@id">
>                     <xforms:label>ID</xforms:label>
>                 </xforms:input>
>             </xforms:repeat>
>
>             <xforms:trigger>
>                 <xforms:label>Add an Input</xforms:label>
>                 <xforms:insert context="/xhtml:html/xhtml:body/
> my:group" nodeset="my:input"
>                     origin="instance('instanceControls')//my:input"
> at="index('repeatControls')"
>                     position="after" ev:event="DOMActivate" />
>             </xforms:trigger>
>             <xforms:trigger>
>                 <xforms:label>Add an Output</xforms:label>
>                 <xforms:insert context="/xhtml:html/xhtml:body/
> my:group" nodeset="my:output"
>                     origin="instance('instanceControls')//my:output"
> at="index('repeatControls')"
>                     position="after" ev:event="DOMActivate" />
>             </xforms:trigger>
>         </xforms:group>
>
>         <div>
>             <strong>Index</strong>
>             <xforms:output value="index('repeatControls')" />
>         </div>
>     </body>
> </html>
>
> Is this a problem of approach or a bug?
>
> Thanks!
>
> Frasre


_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Cannot insert at index in repeat with multiple element types

FraserHore-2
Update: Solved this by simply using the wildcard * in the nodeset
attribute:

            <xforms:trigger>
                <xforms:label>Add an Input</xforms:label>
                <xforms:insert context="/xhtml:html/xhtml:body/
my:group" nodeset="*"
                    origin="instance('instanceControls')//my:input"
at="index('repeatControls')"
                    position="after" ev:event="DOMActivate" />
            </xforms:trigger>
            <xforms:trigger>
                <xforms:label>Add an Output</xforms:label>
                <xforms:insert context="/xhtml:html/xhtml:body/
my:group" nodeset="*"
                    origin="instance('instanceControls')//my:output"
at="index('repeatControls')"
                    position="after" ev:event="DOMActivate" />
            </xforms:trigger>
        </xforms:group>

Now you can enter an input or output anywhere you want in the list,
and you can add an output even if there are no existing outputs in the
list.

Cheers,

Fraser
On Sep 14, 4:26 pm, Fraser <[hidden email]> wrote:

> To put it more simply, you can't add an element of type B between two
> elements of type A.
>
> On Sep 14, 4:22 pm, Fraser <[hidden email]> wrote:
>
> > When inserting an element into a repeat with different element types,
> > the inserted element always stays with other elements of the same
> > type.  At index does work if element of type A has the focus and your
> > are inserting an element of type A.  However if your are inserting an
> > element of type B, it will be inserted at the end of the first list of
> > B elements after the A element.  Please see the test case below:
>
> > <?xml version="1.0" encoding="UTF-8"?>
>
> > <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml"
> >     xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> >     xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:my="http://www.example.com">
>
> >     <head>
> >         <title>Test</title>
> >         <xforms:model>
> >             <xforms:instance id="instanceForm">
> >                 <html xmlns="http://www.w3.org/1999/xhtml"
> >                     xmlns:xforms="http://www.w3.org/2002/xforms"
> > xmlns:my="http://www.example.com">
> >                     <head> </head>
> >                     <body>
> >                         <my:group>
> >                             <my:input ref="" id="input1" />
> >                             <my:input ref="" id="input2" />
> >                             <my:output ref="" id="output1" />
> >                             <my:input ref="" id="input3" />
> >                         </my:group>
> >                     </body>
> >                 </html>
> >             </xforms:instance>
> >             <xforms:instance id="instanceControls">
> >                 <my:group xmlns:xforms="http://www.w3.org/2002/xforms"
> >                     xmlns:my="http://www.example.com">
> >                     <my:input ref="Enter Ref" id="Enter ID" />
> >                     <my:output ref="Enter Ref" id="Enter ID" />
> >                 </my:group>
> >             </xforms:instance>
> >         </xforms:model>
> >         <link href="default.css" rel="stylesheet" />
> >     </head>
>
> >     <body>
>
> >         <xforms:group ref="/xhtml:html/xhtml:body/my:group">
> >             <xforms:label>Controls</xforms:label>
> >             <xforms:repeat nodeset="*" id="repeatControls">
> >                 <xforms:label>
> >                     <xforms:output value="substring(name(.), 4)" />
> >                 </xforms:label>
> >                 <xforms:input ref="@ref">
> >                     <xforms:label>Ref</xforms:label>
> >                 </xforms:input>
> >                 <xforms:input ref="@id">
> >                     <xforms:label>ID</xforms:label>
> >                 </xforms:input>
> >             </xforms:repeat>
>
> >             <xforms:trigger>
> >                 <xforms:label>Add an Input</xforms:label>
> >                 <xforms:insert context="/xhtml:html/xhtml:body/
> > my:group" nodeset="my:input"
> >                     origin="instance('instanceControls')//my:input"
> > at="index('repeatControls')"
> >                     position="after" ev:event="DOMActivate" />
> >             </xforms:trigger>
> >             <xforms:trigger>
> >                 <xforms:label>Add an Output</xforms:label>
> >                 <xforms:insert context="/xhtml:html/xhtml:body/
> > my:group" nodeset="my:output"
> >                     origin="instance('instanceControls')//my:output"
> > at="index('repeatControls')"
> >                     position="after" ev:event="DOMActivate" />
> >             </xforms:trigger>
> >         </xforms:group>
>
> >         <div>
> >             <strong>Index</strong>
> >             <xforms:output value="index('repeatControls')" />
> >         </div>
> >     </body>
> > </html>
>
> > Is this a problem of approach or a bug?
>
> > Thanks!
>
> > Frasre


_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms