bind calculate="" not working as expected

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

bind calculate="" not working as expected

klemm
I'm trying to use the calculate feature but cannot get it working. I think i'm doing something working. I have managed to get this working using value but not bind. You can see to samples below.

Any help would be much appreciated.

Thanks,
Daniel





Output = "a b c d" - WRONG!
<xhtml:html xmlns:xforms="http://www.w3.org/2002/xforms"
                        xmlns:xhtml="http://www.w3.org/1999/xhtml">
        <xhtml:head>
        <xforms:model>
                    <xforms:instance>
                                <root>
                                        <items>
                                                <item>a</item>
                                                <item>b</item>
                                                <item>c</item>
                                                <item>d</item>
                                        </items>
                                </root>
                    </xforms:instance>
                        <xforms:bind nodeset=".">
                                <xforms:bind id="mycount" nodeset="items" calculate="count(*)" />
                        </xforms:bind>
                </xforms:model>
        </xhtml:head>
    <xhtml:body>
                <xforms:output bind="mycount" />
        </xhtml:body>
</xhtml:html>


Output = "4" - CORRECT!
<xhtml:html xmlns:xforms="http://www.w3.org/2002/xforms"
                        xmlns:xhtml="http://www.w3.org/1999/xhtml">
        <xhtml:head>
        <xforms:model>
                    <xforms:instance>
                                <root>
                                        <items>
                                                <item>a</item>
                                                <item>b</item>
                                                <item>c</item>
                                                <item>d</item>
                                        </items>
                                </root>
                    </xforms:instance>
                        <xforms:bind nodeset=".">
                                <xforms:bind id="mycount" nodeset="items" />
                        </xforms:bind>
                </xforms:model>
        </xhtml:head>
    <xhtml:body>
                <xforms:output bind="mycount" value="count(*)" />
        </xhtml:body>
</xhtml:html>




Reply | Threaded
Open this post in threaded view
|

Re: bind calculate="" not working as expected

klemm
I figured this out now.

I needed to bind the calculate to a nodeset when it can store and read its result from.

Thanks,
Daniel