Hi
I Need following data structure in XFORM Repeat A1 | A2 | A3| Accumulative-SUM -------------------------------- 1 | 2 | 3 | 6 -------------------------------- 2 | 2 | 4 | 14 --------------------------------- 3 | 2 | 5 | 24 ----------------------------- If i do that through XForm current index of repeat ID...it always shows the current index sum whereever current cursor positions. Please could you advice something on this. Thanks, Chandra |
Chandra,
Use the postion() XPath function instead of index(). You can store the row position in a variable too: <xforms:repeat ...> <xxforms:variable name="row" select="position()" as="xs:integer"/> ... <xforms:repeat ...> <xxforms:variable name="column" select="position()" as="xs:integer"/> -Erik On Tue, Dec 1, 2009 at 6:54 AM, chandra <[hidden email]> wrote: > > Hi > > I Need following data structure in XFORM Repeat > > > A1 | A2 | A3| Accumulative-SUM > -------------------------------- > 1 | 2 | 3 | 6 > -------------------------------- > 2 | 2 | 4 | 14 > --------------------------------- > 3 | 2 | 5 | 24 > ----------------------------- > > If i do that through XForm current index of repeat ID...it always shows the > current index sum whereever current cursor positions. > > Please could you advice something on this. > > Thanks, > Chandra > > -- > View this message in context: http://n4.nabble.com/Accumulative-sum-in-Repeat-structure-tp932256p932256.html > Sent from the ObjectWeb OPS - Users mailing list archive at Nabble.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 > > -- 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 |
Erik,
Thanks for the reply. currently the position implementation does'nt worked. What i need to implement is in each row i need to calculate sum of column A1 A2 A3 and the previous Accumulative-SUM , Hence in the binding of the Accumulative-Sum i wrote, <xforms:bind nodeset="instance('Flow-instance')/Components/Repeat/CashFlow/Data[position()!=last()]/Accumulative-SUM" id="SomeID"calculate="format-number(sum((../A1, ../A2, ../A3, instance('Flow-instance')/Components/Repeat/CashFlow/Data[position()-1]/Accumulative-SUM)),'#.#')" type="xs:double"/> instance name "Flow-instance" ---------------------------- <DataModel> <Components> <Repeat> <CashFlow> <Data> <A1>1</A1> <A2>2</A2> <A3>3</A3> <Accumulative-SUM>6</Accumulative-SUM> </Data> <Data> <A1>2</A1> <A2>2</A2> <A3>3</A3> <Accumulative-SUM>13</Accumulative-SUM> </Data> <Data> <A1>3</A1> <A2>2</A2> <A3>5</A3> <Accumulative-SUM>23</Accumulative-SUM> </Data> </CashFlow> </Repeat> </Components> </DataModel> The output in Accumulative-SUM column that i am getting is only the sum of A1, A2 and A3. I am not getting the value of the preceeding Accumulative-SUM column added to this total. The output that i am getting is ( sum of A1 A2 and A3 only) A1 | A2 | A3| Accumulative-SUM ---------------------------- 1 | 2 | 3 | 6 ---------------------------- 2 | 2 | 4 | 8 ---------------------------- 3 | 2 | 5 | 10 ----------------------------- Please could you advice something on this. Thanks, Chandra
|
Hi Chandra,
i would do it with xpath Axes (http://www.w3schools.com/Xpath/xpath_axes.asp). You can use 'preceding' here. The following should work: <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:ev="http://www.w3.org/2001/xml-events" xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:fr="http://orbeon.org/oxf/xml/form-runner" xmlns:widget="http://orbeon.org/oxf/xml/widget" lang="de"> <head> <title>Prototype</title> <xforms:model> <xforms:bind nodeset="instance('main')/Components/Repeat/CashFlow/Data/Accumulative-SUM" calculate="format-number(sum((../A1, ../A2, ../A3, preceding::Data[1]/Accumulative-SUM)),'#.#')" type="xs:double"/> <xforms:instance id="main"> <DataModel xmlns=""> <Components> <Repeat> <CashFlow> <Data> <A1>1</A1> <A2>2</A2> <A3>3</A3> <Accumulative-SUM>6</Accumulative-SUM> </Data> <Data> <A1>2</A1> <A2>2</A2> <A3>3</A3> <Accumulative-SUM>13</Accumulative-SUM> </Data> <Data> <A1>3</A1> <A2>2</A2> <A3>5</A3> <Accumulative-SUM>23</Accumulative-SUM> </Data> <Data> <A1>3</A1> <A2>2</A2> <A3>5</A3> <Accumulative-SUM>23</Accumulative-SUM> </Data> </CashFlow> </Repeat> </Components> </DataModel> </xforms:instance> </xforms:model> </head> <body> <xforms:repeat nodeset="instance('main')/Components/Repeat/CashFlow/Data" id="repeat"> <xforms:input ref="A1"> <xforms:label>A1</xforms:label> </xforms:input> <xforms:input ref="A2"> <xforms:label>A2</xforms:label> </xforms:input> <xforms:input ref="A3"> <xforms:label>A3</xforms:label> </xforms:input> <xforms:input ref="Accumulative-SUM"> <xforms:label>Accumulative-SUM</xforms:label> </xforms:input> <br/> </xforms:repeat> </body> </html> ---- Let me know, if this work like you need it and sorry for the bad english. All the best Benjamin
|
Benjamin, Erik
preceding solved the problem of Accumulative Sum in repeat structure. Thanks Your reply is greatly appreciated !!
|
Free forum by Nabble | Edit this page |