Re: [Xsltforms-support] Nested repeat with different instances
Brought to you by:
alain-couthures
From: Elias M. <eli...@gm...> - 2013-03-18 19:42:42
|
Alain and all. Related to my earlier posting for saving a value within a repeat...if you look at the code below, let's say that row and cols data are number and I want to display in red the cells in which the sum of the row and col is larger than 10 for example. For that I need to store the row value as I display the columns so I can add and check if it's greater than 10. How to do it? Thanks. Elias On Sun, Feb 24, 2013 at 4:35 PM, Alain Couthures < ala...@ag...> wrote: > Hello Elias, > > I'm trying to create a spreadsheet where the rows and columns are in >> separate instances, something like: >> >> <xf:instance id="rows"> >> <data xmlns=""> >> <row> >> <rowdata>stuff</rowdata> >> </row> >> <row> >> <rowdata>more stuff</rowdata> >> </row> >> ... >> ... >> </data> >> </xf:instance> >> >> <xf:instance id="cols"> >> <data xmlns=""> >> <col> >> <coldata>stuff</coldata> >> </col> >> <col> >> <coldata>more stuff</coldata> >> </col> >> ... >> ... >> </data> >> </xf:instance> >> >> <xf:repeat id="rows" nodeset="instance('rows')/row"> >> <div><xf:output value="./rowdata"/></div> >> <xf:repeat id="cols" nodeset="instance('cols')/col"> >> <div><xf:output value="./coldata"/> >> <xf:output value="index('rows')"/><br/> >> <xf:output value="index('cols')"/> >> </div> >> </xf:repeat> >> </xf:repeat> >> >> >> There are duplicate ids for instances and repeats and I have rewritten > this test case like this: > > <html xmlns:xforms="http://www.w3.org/2002/xforms" xmlns=" > http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml" > xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xsd=" > http://www.w3.org/2001/XMLSchema"> > <head> > <title>Indexes</title> > <xforms:model> > <xforms:instance id="irows"> > <data xmlns=""> > <row> > <rowdata>datar1</rowdata> > </row> > <row> > <rowdata>datar2</rowdata> > </row> > </data> > </xforms:instance> > <xforms:instance id="icols"> > <data xmlns=""> > <col> > <coldata>datac1</coldata> > </col> > <col> > <coldata>datac2</coldata> > </col> > </data> > </xforms:instance> > </xforms:model> > </head> > <body> > <xforms:repeat id="rows" nodeset="instance('irows')/row"> > <div><xforms:output value="./rowdata"/></div> > <xforms:repeat id="cols" nodeset="instance('icols')/col"> > <div><xforms:output value="./coldata"/> > <br/> > Current row:<xforms:output value="index('rows')"/><br/> > Current col:<xforms:output value="index('cols')"/> > </div> > </xforms:repeat> > </xforms:repeat> > </body> > </html> > > I can see an issue with the index() function for the cols repeat because > clicking on the last column item in the second row does not have any effect > on this index. > > I think that it is because it is a cloned node and I can surely fix this. > > Are you in a hurry? > > -Alain > > |