Re: [Xsltforms-support] Nested repeat with different instances
Brought to you by:
alain-couthures
From: Alain C. <ala...@ag...> - 2013-02-24 21:42:12
|
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 |