Issue with nested xf:repeat tags where the second xf:repeat only ever has the value of 1

RESOLVED WONTFIX

Status

Core Graveyard
XForms
RESOLVED WONTFIX
11 years ago
2 years ago

People

(Reporter: Alex Bleasdale, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

11 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7

I've found that if I nest an xf:repeat within an xf:repeat (i.e. to make selections based on groups of things), and try to get the position of both points, I can always retrieve the point of the first repeat loop, but not the one nested inside it. 

I've created a fairly simple example of the problem and uploaded it here - http://proptax.mdor.state.mn.us:9780/xfrepeat/

If you check the test URL in firefox, you can see the 'selected index' works for the nested repeats (as in, it will show you what you have selected), but no matter where I click in the second loop, the value of value 2 is always set to 1 

Apologies if this posting is a duplicate - I looked around but couldn't find anything similar.

Reproducible: Always

Steps to Reproduce:
1. Go to: http://proptax.mdor.state.mn.us:9780/xfrepeat/
2. select the third item of the third genre ((soul),(and another soul star))
3. value 1 should show 3 (expected), value 2 shows 1 (3 expected)
4. select the second item of the third genre (another soul star)
5. 3. value 1 should show 3 (expected), value 2 shows 1 (2 expected)
Actual Results:  
You should see this on the page:

value 1: 3
value 2: 1

Note that value 2 will not change.

Expected Results:  
value 2 should change to represent the position within the repeat (i.e. should show 1,2 and 3 respectively as you select the different input fields for that repeat set)

-------------  The xhtml for the form (index.xhtml) ------------

<?xml version="1.0" encoding="UTF-8"?>
<?oxygen NVDLSchema="file:/C:/Program%20Files/Oxygen%20XML%20Editor%208.2/samples/nvdl/xhtml-xforms.nvdl"?>
<html xmlns:xf="http://www.w3.org/2002/xforms"  xmlns="http://www.w3.org/1999/xhtml" >

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>Test</title>

        <style type="text/css">
            @namespace xf url("http://www.w3.org/2002/xforms");
            #repeat-set-two {margin-left:5em;}
            xf|repeat .xf-repeat-index {background:#ccc;}
            xf|repeat xf|repeat  .xf-repeat-index {background:#aaa;}
        </style>

        <xf:model id="music-test">
            <xf:instance id="my-music" src="music-collection.xml"></xf:instance>
         </xf:model>
    </head>

    <body>

<xf:group id="test">
        <xf:repeat id="repeat-set-one" nodeset="/music/genres/genre">
            <xf:output value="position()"></xf:output>
            <xf:input ref="name">
                <xf:label>genre name: </xf:label>
            </xf:input>
            <!-- nested repeatset goes here -->
            <xf:repeat id="repeat-set-two" nodeset="artists/artist">
                <xf:output value="position()"></xf:output>
                <xf:input ref="name">
                    <xf:label>artist name: </xf:label>
                </xf:input>
            </xf:repeat>

         </xf:repeat>
</xf:group>


<xf:group id="albums" ref="/music/genres/genre[index('repeat-set-one')]/artists/artist/name[index('repeat-set-two')]">
    <xf:label>albums by this artist:</xf:label>
    <p>
        <xf:output value="index('repeat-set-one')">
            <xf:label>value 1: </xf:label>
        </xf:output>
    </p>
    <p>
        <xf:output value="index('repeat-set-two')">
            <xf:label>value 2: </xf:label>
        </xf:output>
    </p>

    <xf:input ref="../albums/album[1]">
        <xf:label>name of first album: </xf:label>
    </xf:input>


</xf:group>

    </body>
</html>

-------------  Some test xml (music-collection.xml) ------------

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

        <genre>
            <name>pop</name>
            <artists>
                <artist>
                    <name>britney spears</name>
                    <albums>
                        <album>britneys first album</album>
                        <album>britneys second album</album>
                        <album>britneys third album</album>
                    </albums>
                </artist>
            </artists>
            <artists>
                <artist>
                    <name>another pop star</name>
                    <albums>
                        <album>another first album</album>
                        <album>another second album</album>
                        <album>another third album</album>
                    </albums>
                </artist>
            </artists>
        </genre>

        <genre>
            <name>jazz</name>
            <artists>
                <artist>
                    <name>miles davies</name>
                    <albums>
                        <album>his first album</album>
                        <album>his second album</album>
                    </albums>
                </artist>
                <artist>
                    <name>another jazz musician</name>
                    <albums>
                        <album>his first album</album>
                        <album>his second album</album>
                    </albums>
                </artist>

            </artists>
        </genre>

        <genre>
            <name>soul</name>
            <artists>
                <artist>
                    <name>soul ii soul</name>
                    <albums>
                        <album>the first soul2soul album</album>
                        <album>the second soul2soul album</album>
                    </albums>
                </artist>
                <artist>
                    <name>another soul star</name>
                    <albums>
                        <album>soul album IV</album>
                        <album>soul album V</album>
                    </albums>
                </artist>
                <artist>
                    <name>and another soul star</name>
                    <albums>
                        <album>soul album IV</album>
                        <album>soul album V</album>
                    </albums>
                </artist>
            </artists>
        </genre>

    </genres>
</music>

Comment 1

10 years ago
I think that the problem that 'dr.cw.ray' reported in this message - <http://groups.google.com/group/mozilla.dev.tech.xforms/msg/79efca0266644b3a> - may be at least in part because of this bug.  I added an output to display the various repeat indices (as Alex did in his bug report for this bug), and I get the same results, only for a third nested repeat, the index is always 0.  I think there may be more to dr.cw.ray's problem, so I'm going to continue investigating.
RIP xforms
Status: UNCONFIRMED → RESOLVED
Last Resolved: 2 years ago
Resolution: --- → WONTFIX
(Assignee)

Updated

2 years ago
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.