Thread: Re: [Xsltforms-support] stepping through recordset type data display
Brought to you by:
alain-couthures
From: Stephen C. <Ste...@ut...> - 2010-01-05 23:02:58
|
Hi Tambet, I have elaborated the test case that you sent me and it works (see below). My code is doing basically the same thing so I must have made a mistake somewhere, so I'll start again with something simple and redo everything to see where it fails. Thanks <?xml version="1.0" encoding="UTF-8"?> <!-- Created with Liquitem XML Studio - FREE Community Edition 7.0.4.795 (http://www.liquitem-technologies.com) --> <?xml-stylesheet href="forms/xsltforms/xsltforms.xsl" type="text/xsl"?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events"> <head> <xf:model id="model1"> <xf:instance id="data"> <data xmlns=""> <item id="1"> <p1>1-1</p1> <p2>1-2</p2> <p3>1-3</p3> </item> <item id="2"> <p1>2-1</p1> <p2>2-2</p2> <p3>2-3</p3> </item> <item id="3"> <p1>3-1</p1> <p2>3-2</p2> <p3>3-3</p3> </item> <item id="4"> <p1>4-1</p1> <p2>4-2</p2> <p3>4-3</p3> </item> <item id="5"> <p1>5-1</p1> <p2>5-2</p2> <p3>5-3</p3> </item> </data> </xf:instance> <xf:instance id="temp"> <data xmlns=""> <selected_item>3</selected_item> </data> </xf:instance> </xf:model> </head> <body> <xf:select1 ref="instance('temp')/selected_item"> <xf:itemset nodeset="instance('data')/item"> <xf:value ref="@id"/> <xf:label ref="@id"/> </xf:itemset> </xf:select1> <xf:group ref="instance('data')/item[@id = instance('temp')/selected_item]"> <br/> <xf:output ref="p1"> <xf:label>Property 1 = </xf:label> </xf:output> <br/> <xf:output ref="p2"> <xf:label>Property 2 = </xf:label> </xf:output> <br/> <xf:output ref="p3"> <xf:label>Property 3 = </xf:label> </xf:output> </xf:group> <br /> <div id="console" style="display:block;top:100px;" /> </body> </html> -------- Original Message -------- Subject: Re: [Xsltforms-support] stepping through recordset type data display Date: Tue, 05 Jan 2010 10:01:28 +0200 From: Tambet Matiisen <tam...@gm...> To: Stephen Cameron <Ste...@ut...> CC: xsl...@li... References: <4B4...@ut...> Stephen Cameron wrote: > Hello, > > I have a specific problem where I wish to select a record from a > xf:select1 list and then on on the basis of the selected value display a > full record below it. > > The full record will be displayed with the use of a xf:group tag, so I > am a really wanting to dynamically change the node the group references > via its 'ref 'or 'bind' attribute Something like this should work: <xforms:select1 ref="instance('temp')/selected_id"> <xforms:itemset nodeset="instance('data')/item"> <xforms:value ref="id"/> <xforms:label ref="label"/> </xforms:itemset> </xforms:select1> <xforms:group ref="instance('data')/item[id = instance('temp')/selected_id]"> <xforms:output ref="id">...</xforms:output> <xforms:output ref="label">...</xforms:output> </xforms:group> Tambet -- Regards Stephen Cameron Data Programmer Integrated Marine Observing System (IMOS) eMarine Information Infrastructure Project University of Tasmania, Private Bag 21, Hobart, TAS 7001, Australia Tel: +61 3 6226 8507 Fax: +61 3 6226 2997 Email: ste...@ut... URL: http://www.imos.org.au/eMII.html |
From: Stephen C. <Ste...@ut...> - 2010-01-06 02:10:33
|
I've found my error which was a silly mistake on my part (a bad tradesman always blames his tools!!), thanks for the help! I was taking the wrong element value in the second xf:select list to use as the id to fill the xf:group, it was staring me in the face yesterday. -- Regards Stephen Cameron Data Programmer Integrated Marine Observing System (IMOS) eMarine Information Infrastructure Project University of Tasmania, Private Bag 21, Hobart, TAS 7001, Australia Tel: +61 3 6226 8507 Fax: +61 3 6226 2997 Email: ste...@ut... URL: http://www.imos.org.au/eMII.html |
From: Stephen C. <Ste...@ut...> - 2010-01-07 11:20:19
|
For those interested (not really specifically an XSLTForms issue) I have been playing with this problem a bit further. The following demo illustrates what I am wanting to do. There is one final problem in the code that I've not gotten to work, its the line that is commented out. Hopefully it's self explanatory Cheers. <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl"?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events"> <head> <xf:model id="m1"> <xf:instance id="data"> <data xmlns=""> <item id="A" name="item 1"> <p1>1-1</p1> <p2>1-2</p2> <p3>1-3</p3> </item> <item id="B" name="item 2"> <p1>2-1</p1> <p2>2-2</p2> <p3>2-3</p3> </item> <item id="C" name="item 3"> <p1>3-1</p1> <p2>3-2</p2> <p3>3-3</p3> </item> <item id="D" name="item 4"> <p1>4-1</p1> <p2>4-2</p2> <p3>4-3</p3> </item> <item id="E" name="item 5"> <p1>5-1</p1> <p2>5-2</p2> <p3>5-3</p3> </item> <item id="F" name="item 6"> <p1>6-1</p1> <p2>6-2</p2> <p3>6-3</p3> </item> <item id="G" name="item 7"> <p1>7-1</p1> <p2>7-2</p2> <p3>7-3</p3> </item> <item id="H" name="item 8"> <p1>8-1</p1> <p2>8-2</p2> <p3>8-3</p3> </item> <item id="I" name="item 9"> <p1>9-1</p1> <p2>9-2</p2> <p3>9-3</p3> </item> <item id="J" name="item 10"> <p1>10-1</p1> <p2>10-2</p2> <p3>10-3</p3> </item> </data> </xf:instance> <xf:instance id="temp"> <data xmlns="" id="" position="0" min="0" max="0" /> </xf:instance> <xf:action ev:event="xforms-model-construct-done"> <xf:setvalue ref="instance('temp')/@id" value="instance('data')/item[1]/@id" /> <xf:setvalue ref="instance('temp')/@min" value="if(count(instance('data')/item)>0,1,0)" /> <xf:setvalue ref="instance('temp')/@max" value="count(instance('data')/item)" /> <xf:setvalue ref="instance('temp')/@position" value="if(../@max>0,1,0)" /> </xf:action> </xf:model> </head> <body> <xf:select1 ref="instance('temp')/@id"> <xf:itemset nodeset="instance('data')/item"> <xf:value ref="@id" /> <xf:label ref="@name" /> </xf:itemset> <!--xf:setvalue ev:event="xforms-value-changed" ref="../@position" value="count(instance('data')/item[@id=instance('temp')/@id]/preceding-sibling:item)+1"/--> </xf:select1> <xf:trigger> <xf:label>|<</xf:label> <xf:setvalue ev:event="DOMActivate" ref="instance('temp')/@position" value="../@min"/> <xf:setvalue ev:event="DOMActivate" ref="instance('temp')/@id" value="instance('data')/item[position()=instance('temp')/@position]/@id"/> </xf:trigger> <xf:trigger> <xf:label><</xf:label> <xf:setvalue ev:event="DOMActivate" ref="instance('temp')/@position" value="if(.=../@min,.,.-1)"/> <xf:setvalue ev:event="DOMActivate" ref="instance('temp')/@id" value="instance('data')/item[position()=instance('temp')/@position]/@id"/> </xf:trigger> <xf:trigger> <xf:label>></xf:label> <xf:setvalue ev:event="DOMActivate" ref="instance('temp')/@position" value="if(.=../@max,.,.+1)"/> <xf:setvalue ev:event="DOMActivate" ref="instance('temp')/@id" value="instance('data')/item[position()=instance('temp')/@position]/@id"/> </xf:trigger> <xf:trigger> <xf:label>>|</xf:label> <xf:setvalue ev:event="DOMActivate" ref="instance('temp')/@position" value="../@max"/> <xf:setvalue ev:event="DOMActivate" ref="instance('temp')/@id" value="instance('data')/item[position()=instance('temp')/@position]/@id"/> </xf:trigger> <xf:group ref="instance('temp')"> <xf:output ref="./@position"/> <xf:output ref="if(./@min>0,' of ','')"/> <xf:output ref="./@max"/> </xf:group> <xf:group ref="instance('data')/item[@id = instance('temp')/@id]"> <br /> <xf:output ref="p1"> <xf:label>Property 1 = </xf:label> </xf:output> <br /> <xf:output ref="p2"> <xf:label>Property 2 = </xf:label> </xf:output> <br /> <xf:output ref="p3"> <xf:label>Property 3 = </xf:label> </xf:output> </xf:group> <br /> <div id="console" style="display:block;top:100px;" /> </body> </html> -- Regards Stephen Cameron Data Programmer Integrated Marine Observing System (IMOS) eMarine Information Infrastructure Project University of Tasmania, Private Bag 21, Hobart, TAS 7001, Australia Tel: +61 3 6226 8507 Fax: +61 3 6226 2997 Email: ste...@ut... URL: http://www.imos.org.au/eMII.html |
From: Tambet M. <tam...@gm...> - 2010-01-07 11:26:17
|
Stephen Cameron wrote: > <!--xf:setvalue ev:event="xforms-value-changed" > ref="../@position" > value="count(instance('data')/item[@id=instance('temp')/@id]/preceding-sibling:item)+1"/--> > This should work: <xf:setvalue ev:event="xforms-value-changed" ref="../@position" value="instance('data')/item[@id=instance('temp')/@id]/position()"/> Tambet |
From: Stephen C. <Ste...@ut...> - 2010-01-07 23:56:40
|
Tambet Matiisen wrote: > Stephen Cameron wrote: >> <!--xf:setvalue ev:event="xforms-value-changed" >> ref="../@position" >> value="count(instance('data')/item[@id=instance('temp')/@id]/preceding-sibling::item)+1"/--> >> >> > This should work: > > <xf:setvalue ev:event="xforms-value-changed" ref="../@position" > value="instance('data')/item[@id=instance('temp')/@id]/position()"/> > > Tambet > > No, I'm afraid not. I think that my solution is correct after doing some more reading, but it gives an error in XSLTForms (see below). So I think that XSLTForms does not support preceding-sibling::, this may be an XForms 1.0 vs 1.1 difference (e.g. choose() is not supported but if() is) XSLTForms Exception -------------------------- Error parsing the following XPath expression : count(instance('data')/item[@id=instance('temp')/@id]/preceding-sibling::item)+1 Unknown operator at ':item)+1' in 'count(instance('data')/item[@id=instance('temp')/@id]/preceding-sibling::item)+1' -- Regards Stephen Cameron Data Programmer Integrated Marine Observing System (IMOS) eMarine Information Infrastructure Project University of Tasmania, Private Bag 21, Hobart, TAS 7001, Australia Tel: +61 3 6226 8507 Fax: +61 3 6226 2997 Email: ste...@ut... URL: http://www.imos.org.au/eMII.html |
From: COUTHURES A. <ala...@ag...> - 2010-01-08 20:03:52
|
Hi Stephen, > I think that XSLTForms does not support preceding-sibling:: I have just added XPath named axes support in XSLTForms latest SVN version. This is a not very much tested yet feature... Cheers, -Alain |