Thread: [Xsltforms-support] select1 behaviour
Brought to you by:
alain-couthures
From: Stephen C. <Ste...@ut...> - 2010-01-24 11:42:19
|
Hello, I have a couple of questions regarding the behaviour of select1 xforms controls. I'd appreciate it if someone could fill me in on what they should and should not be able to do. The following is a test case: <?xml version="1.0" encoding="UTF-8"?> <?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" xmlns:aatams="http://www.imos.org.au/aatams" xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" xmlns:ows="http://www.opengis.net/ows" xmlns:gml="http://www.opengis.net/gml" > <head> <xf:model id="m1"> <xf:instance id="template"> <wfs:Insert> <wfs:FeatureCollection> <gml:featureMember> <aatams:device> <aatams:name/> <aatams:device_type_ref> <aatams:device_type gml:id="aatams.device_type.2"> <aatams:name>TRANSMITTER</aatams:name> </aatams:device_type> </aatams:device_type_ref> </aatams:device> </gml:featureMember> </wfs:FeatureCollection> </wfs:Insert> </xf:instance> <xf:instance id="types" > <wfs:FeatureCollection> <gml:featureMember> <aatams:device_type gml:id="aatams.device_type.1"> <aatams:name>RECEIVER</aatams:name> </aatams:device_type> </gml:featureMember> <gml:featureMember> <aatams:device_type gml:id="aatams.device_type.2"> <aatams:name>TRANSMITTER</aatams:name> </aatams:device_type> </gml:featureMember> </wfs:FeatureCollection> </xf:instance> </xf:model> </head> <body> <xf:group ref="instance('template')//aatams:device"> <xf:input ref="aatams:name" > <xf:label>Device Name:</xf:label> </xf:input> <br/> <xf:select1 ref="aatams:device_type_ref/aatams:device_type"> <xf:label>Device Type: </xf:label> <xf:itemset nodeset="instance('types')/gml:featureMember/aatams:device_type"> <xf:value ref="." /> <xf:label ref="aatams:name" /> </xf:itemset> </xf:select1> </xf:group> <br/> <xf:output ref="instance('template')//aatams:device/aatams:device_type_ref/aatams:device_type/aatams:name" > <xf:label>Device Type Name:</xf:label> </xf:output> <div id="console" style="display:block;top:100px;" /> </body> </html> My aim is to replace the aatams:device_type node in the 'template' instance with another aatams:device_type (node and children ) selected by the user in the xf:select1 control. However this test case doesn't work, the xf:output does not change its value. The xf:select1 control by the Xforms standard has a "single-node-binding", it seems that by this the standard actually means a single text node or an attribute if the above test does not work. This is an important question as being not being able to replace a complex node in an instance complicates matter considerably. At the moment I am forced to build an instance at the time of submission using the ids of all the complex elements that the user has selected and which have been saved into another instance via bindings. This is not the correct way to be doing this I'm sure as it now prevents me from doing other things, like using templates, saving partly completed forms and retrieving them later, and creating new complex sub-elements. Particularly when you consider another issue as follows: If the nodes in nodeset that is used in the xf:select1 are more complex than the above example (which is nearly all the time for me) then it would be very desirable to be able to include a more complex 'compound' value in the xf:label of the xf:itemset. Here is an example. I have a list of receiver deployments. I want the user to be able to select a deployment from a list. The only way the user can tell which deployment is the correct one is to know 'where', 'what' and 'when', so the label needs to be a concatenation of three elements from each itemset node; where the deployment occurred (a 'station' name), what was deployed ( a receiver 'code-name') and the date of deployment. To get these three values strung together I currently have to have a view in my database that does the concatenation and use this extra 'feature' published as xml by my webservice to build my nodeset and then based on the xf:value value of the node selected by the user in the select1 itemlist, find the correct aatams:receiver_deployment 'single-node' and stick it into the template. So to clarify my ideal nodeset would be something like <xf:itemset nodeset="instance('deployments')/gml:featureMember/aatams:receiver_deployment"> <xf:value ref="." /> <xf:label ref="concatenate(aatams:installation/aatams:station/aatams:name,'-',aatams:receiver/aatams:code_name,'-',aatams:deployment_date )"> </xf:itemset> It would also be good to be able to sort the nodeset as well, in the same manner as XSLT perhaps. So hopefully from these two examples I have shown that what should be very simple has become quite complicated and definitely not what Xforms is supposed to be about! Thanks for your interest. -- 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/eM .html |
From: Tambet M. <tam...@gm...> - 2010-01-25 08:48:06
|
Stephen Cameron wrote: > My aim is to replace the aatams:device_type node in the 'template' > instance with another aatams:device_type (node and children ) selected > by the user in the xf:select1 control. However this test case doesn't > work, the xf:output does not change its value. The xf:select1 control by > the Xforms standard has a "single-node-binding", it seems that by this > the standard actually means a single text node or an attribute if the > above test does not work. > Isn't the <xforms:copy> element meant for this case? See http://www.w3.org/TR/2003/REC-xforms-20031014/index-all.html#ui-adv-copy I don't know if XSLTForms supports the <xforms:copy> element. > So to clarify my ideal nodeset would be something like > > <xf:itemset > nodeset="instance('deployments')/gml:featureMember/aatams:receiver_deployment"> > <xf:value ref="." /> > <xf:label > ref="concatenate(aatams:installation/aatams:station/aatams:name,'-',aatams:receiver/aatams:code_name,'-',aatams:deployment_date > )"> > </xf:itemset> > I'm not sure if this works (or even should work) for <xf:itemset> labels, but it surely works for <xf:output> labels, at least in Chiba. <xf:label><xf:output value="concat(aatams:installation/aatams:station/aatams:name,'-',aatams:receiver/aatams:code_name,'-',aatams:deployment_date )"/></xf:label> Tambet |
From: Klotz, L. <Lei...@xe...> - 2010-01-25 16:45:42
|
I think you want xf:select/itemset/copy instead of xf:select1/itemset/value. I'm not sure that XSLTForms implements it, though. Check your copy of Micah Dubinko's XForms book p. 101 (or search Google Books copy for "xforms select copy"). You might also be able to coook something up by imitating select with a switch and using insert and delete. For how to use insert and delete (XForms 1.1 version) see http://www.w3.org/TR/xforms11/#data-mutation-patterns XForms 1.1 defines select/itemset/copy in terms of insert and delete, and XForms 1.2 is proposed to add a merged version of select and switch, so it wouldn't be that far off. Leigh. -----Original Message----- From: Stephen Cameron [mailto:Ste...@ut...] Sent: Sunday, January 24, 2010 3:42 AM To: xsl...@li... Subject: [Xsltforms-support] select1 behaviour Hello, I have a couple of questions regarding the behaviour of select1 xforms controls. I'd appreciate it if someone could fill me in on what they should and should not be able to do. The following is a test case: <?xml version="1.0" encoding="UTF-8"?> <?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" xmlns:aatams="http://www.imos.org.au/aatams" xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" xmlns:ows="http://www.opengis.net/ows" xmlns:gml="http://www.opengis.net/gml" > <head> <xf:model id="m1"> <xf:instance id="template"> <wfs:Insert> <wfs:FeatureCollection> <gml:featureMember> <aatams:device> <aatams:name/> <aatams:device_type_ref> <aatams:device_type gml:id="aatams.device_type.2"> <aatams:name>TRANSMITTER</aatams:name> </aatams:device_type> </aatams:device_type_ref> </aatams:device> </gml:featureMember> </wfs:FeatureCollection> </wfs:Insert> </xf:instance> <xf:instance id="types" > <wfs:FeatureCollection> <gml:featureMember> <aatams:device_type gml:id="aatams.device_type.1"> <aatams:name>RECEIVER</aatams:name> </aatams:device_type> </gml:featureMember> <gml:featureMember> <aatams:device_type gml:id="aatams.device_type.2"> <aatams:name>TRANSMITTER</aatams:name> </aatams:device_type> </gml:featureMember> </wfs:FeatureCollection> </xf:instance> </xf:model> </head> <body> <xf:group ref="instance('template')//aatams:device"> <xf:input ref="aatams:name" > <xf:label>Device Name:</xf:label> </xf:input> <br/> <xf:select1 ref="aatams:device_type_ref/aatams:device_type"> <xf:label>Device Type: </xf:label> <xf:itemset nodeset="instance('types')/gml:featureMember/aatams:device_type"> <xf:value ref="." /> <xf:label ref="aatams:name" /> </xf:itemset> </xf:select1> </xf:group> <br/> <xf:output ref="instance('template')//aatams:device/aatams:device_type_ref/aatams:device_type/aatams:name" > <xf:label>Device Type Name:</xf:label> </xf:output> <div id="console" style="display:block;top:100px;" /> </body> </html> My aim is to replace the aatams:device_type node in the 'template' instance with another aatams:device_type (node and children ) selected by the user in the xf:select1 control. However this test case doesn't work, the xf:output does not change its value. The xf:select1 control by the Xforms standard has a "single-node-binding", it seems that by this the standard actually means a single text node or an attribute if the above test does not work. This is an important question as being not being able to replace a complex node in an instance complicates matter considerably. At the moment I am forced to build an instance at the time of submission using the ids of all the complex elements that the user has selected and which have been saved into another instance via bindings. This is not the correct way to be doing this I'm sure as it now prevents me from doing other things, like using templates, saving partly completed forms and retrieving them later, and creating new complex sub-elements. Particularly when you consider another issue as follows: If the nodes in nodeset that is used in the xf:select1 are more complex than the above example (which is nearly all the time for me) then it would be very desirable to be able to include a more complex 'compound' value in the xf:label of the xf:itemset. Here is an example. I have a list of receiver deployments. I want the user to be able to select a deployment from a list. The only way the user can tell which deployment is the correct one is to know 'where', 'what' and 'when', so the label needs to be a concatenation of three elements from each itemset node; where the deployment occurred (a 'station' name), what was deployed ( a receiver 'code-name') and the date of deployment. To get these three values strung together I currently have to have a view in my database that does the concatenation and use this extra 'feature' published as xml by my webservice to build my nodeset and then based on the xf:value value of the node selected by the user in the select1 itemlist, find the correct aatams:receiver_deployment 'single-node' and stick it into the template. So to clarify my ideal nodeset would be something like <xf:itemset nodeset="instance('deployments')/gml:featureMember/aatams:receiver_deployment"> <xf:value ref="." /> <xf:label ref="concatenate(aatams:installation/aatams:station/aatams:name,'-',aatams:receiver/aatams:code_name,'-',aatams:deployment_date )"> </xf:itemset> It would also be good to be able to sort the nodeset as well, in the same manner as XSLT perhaps. So hopefully from these two examples I have shown that what should be very simple has become quite complicated and definitely not what Xforms is supposed to be about! Thanks for your interest. -- 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/eM .html ------------------------------------------------------------------------------ Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev _______________________________________________ Xsltforms-support mailing list Xsl...@li... https://lists.sourceforge.net/lists/listinfo/xsltforms-support |