Hi,
I have a repeat table and inside each row I have two xforms:select1. What I would like is to link the two selects in order when the first select changes, the list of selectables values of the second select changes. Below I paste my example that has a select1 for countries and a select1 for cities. So when the country changes the list of selectable cities should change accordingly. Does anybody know if this is possible and how can I implement this. I've looked at the examples but didn't find any solution. ************This is my instance(countries): <countries> <country> <name>Spain</name> <id>0</id> <cities> <city> <name>Barcelona</name> <id>0</id> </ city > <city> <name>Madrid</name> <id>1</id> </ city > </ cities > </ country > <country> <name>France</name> <id>0</id> <cities> <city> <name>Paris</name> <id>0</id> </ city > <city> <name>Toulouse</name> <id>1</id> </ city > </ cities > </ country > </ countries > ************This is my xforms inside the repeat: <xhtml:tr> <xhtml:td class="estilo1">Country</xhtml:td> <xhtml:td align="right"> <xforms:select1 appearance="minimal" ref=" @selcountry"> <xforms:itemset nodeset="instance(countries)/country"> <xforms:label ref="name"></xforms:label> <xforms:value ref="id"></xforms:value> </xforms:itemset> </xforms:select1> </xhtml:td> </xhtml:tr> <xhtml:tr> <xhtml:td class="estilo1">City</xhtml:td> <xhtml:td align="right"> <xforms:select1 appearance="minimal" ref="@selcity"> <xforms:itemset nodeset=" instance(countries)/country [index(i)]/cities/city "> <xforms:label ref="name"></xforms:label> <xforms:value ref="id"></xforms:value> </xforms:itemset> </xforms:select1> </xhtml:td> </xhtml:tr> Thanks in advance, Jordi -- 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 ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
There seems to often be several potential solutions to a problem. For this particular one, I do not think I would use any repeat statements, but instead rely on the itemset node in the select1 element.
Here is my approach: 1. Use the itemset attribute on the select1 element to get the list of values 2. Once a value has been selected in the first box, copy the associated values for the second select box to a new instance/location 3. Have the second select1 box list values from this new instance/location This is just form the top of my head, so its probably not 100% correct. But it should show you what I mean :-) instance="first-select-box-instance" <first> <first-select-box> <value/> <value/> <value/> ... </first-select-box> <second-select-box> <selected-value/> <allowed> <value/> <value/> <value/> ... </allowed> </second-select-box> </first> instance="main-instance" <main> <first-select-box> <value/> <second-select-box> <value/> <value/> <value/> ... </values> </second-select-box> </first-select-box> <first-select-box> <value/> <second-select-box> <values> <value/> <value/> <value/> ... </values> </second-select-box> </first-select-box> ... </main> ... <xforms:select1 ref="instance('first-select-box-instance')/first-select-box/value" id="repeat-1"> <xforms:itemset nodeset="instance('main-instance')first-select-box/value"> <xforms:label ref="value"/> <xforms:value ref="value"/> </xforms:itemset> <xforms:action ev:event="DOMActivate"> <xforms:setvalue ref="instance('first-select-box-instance'')/second-select-box/allowed" value="'instance('main-instance')/first-select-box[index('repeat-1')]/second-select-box/allowed" </xforms:action> </xforms:select1> <xforms:select1 ref="instance('first-select-box-instance')/first-select-box/second-select-box/selected-value" id="repeat-2"> <xforms:itemset nodeset="instance('first-select-box-instance')/first-select-box/values"> <xforms:label ref="value"/> <xforms:value ref="value"/> </xforms:itemset> </xforms:select1> ... Hope this helps! Henrik On 8/22/06, [hidden email] <[hidden email]> wrote: > Hi, > > I have a repeat table and inside each row I have two xforms:select1. > What I would like is to link the two selects in order when the first select changes, the list of selectables values of the second select changes. > Below I paste my example that has a select1 for countries and a select1 for cities. So when the country changes the list of selectable cities should change accordingly. > > Does anybody know if this is possible and how can I implement this. I've looked at the examples but didn't find any solution. > > ************This is my instance(countries): > > <countries> > <country> > <name>Spain</name> > <id>0</id> > <cities> > <city> > <name>Barcelona</name> > <id>0</id> > </ city > > <city> > <name>Madrid</name> > <id>1</id> > </ city > > </ cities > > </ country > > <country> > <name>France</name> > <id>0</id> > <cities> > <city> > <name>Paris</name> > <id>0</id> > </ city > > <city> > <name>Toulouse</name> > <id>1</id> > </ city > > </ cities > > </ country > > </ countries > > > ************This is my xforms inside the repeat: > > > <xhtml:tr> > <xhtml:td class="estilo1">Country</xhtml:td> > <xhtml:td align="right"> > <xforms:select1 appearance="minimal" ref=" @selcountry"> > <xforms:itemset nodeset="instance('countries')/country"> > <xforms:label ref="name"></xforms:label> > <xforms:value ref="id"></xforms:value> > </xforms:itemset> > </xforms:select1> > </xhtml:td> > </xhtml:tr> > <xhtml:tr> > <xhtml:td class="estilo1">City</xhtml:td> > <xhtml:td align="right"> > <xforms:select1 appearance="minimal" ref="@selcity"> > <xforms:itemset nodeset=" instance('countries')/country [index('i')]/cities/city "> > <xforms:label ref="name"></xforms:label> > <xforms:value ref="id"></xforms:value> > </xforms:itemset> > </xforms:select1> > </xhtml:td> > </xhtml:tr> > > > Thanks in advance, > Jordi > > > > > -- > 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 > ObjectWeb mailing lists service home page: http://www.objectweb.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 ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
small correction.....
instance="first-select-box-instance" <first> <first-select-box> <selected-value/> </first-select-box> <second-select-box> <selected-value/> <allowed> <value/> <value/> <value/> ... </allowed> </second-select-box> </first> instance="main-instance" <main> <first-select-box> <value/> <second-select-box> <values> <value/> <value/> <value/> ... </values> </second-select-box> </first-select-box> <first-select-box> <value/> <second-select-box> <values> <value/> <value/> <value/> ... </values> </second-select-box> </first-select-box> ... </main> ... <xforms:select1 ref="instance('first-select-box-instance')/first-select-box/selected-value" id="repeatA"> <xforms:itemset nodeset="instance('main-instance')first-select-box/values"> <xforms:label ref="value"/> <xforms:value ref="value"/> </xforms:itemset> <xforms:action ev:event="DOMActivate"> <xforms:setvalue ref="instance('first-select-box-instance'')/second-select-box/allowed/*" value="'instance('main-instance')/first-select-box[index('repeatA')]/second-select-box/allowed" </xforms:action> </xforms:select1> <xforms:select1 ref="instance('first-select-box-instance')/second-select-box/selected-value" id="repeatB"> <xforms:itemset nodeset="instance('first-select-box-instance')/second-select-box/allowed"> <xforms:label ref="value"/> <xforms:value ref="value"/> </xforms:itemset> </xforms:select1> ... On 8/23/06, Henrik Pettersen <[hidden email]> wrote:
-- 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 ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Or, a different approach:
<xforms:instance id="selection"> <selection> <contry/> <city/> </selection> </xforms:instance> <xforms:instance id="countries"> <countries> <country selected="true()"> <name>Norway</name> <selected>true</selected> <!-- default selection --> <city>oslo</city> <city>bergen</city> <city>trondheim</city> </country> <country selected="false()"> <name>Sweden</name> <selected>false</selected> <city>Goteborg</city> <city>Stockholm</city> </country> <country selected="false()"> <name>France</name> <selected>false</selected> <city>Paris</city> <city>Niece</city> </country> </countries> </xforms:instance> ... <xforms:select1 ref="instance('selection')/country" id="select-country"> <xforms:itemset nodeset="instance('countries')/country" id="countries-itemset"> <xforms:label ref="name"/> <xforms:value ref="name"/> </xforms:itemset> <xforms:action ev:event="DOMActivate"> <xforms:setvalue ref="instance('countries')/country/selected[.=true]">false</xforms:setvalue> <!-- reset --> <xforms:setvalue ref="instance('countries')/country[index('countries-itemset')]/selected">true</xforms:setvalue> </xforms:action> </xforms:select1> <xforms:select1 ref="instance('selection')/city" id="select-city"> <xforms:itemset nodeset="instance('countries')/country/selected[.=true]/city"> <xforms:label ref="."/> <xforms:value ref="."/> </xforms:itemset> </xforms:select1> ... Haven't tried this out, but hopefully its good for some inspiration! Hope that helps. Henrik On 8/23/06, Henrik Pettersen <[hidden email]> wrote:
-- 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 ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Thanks Henrik for your ideas
that helped me to understand better xforms. Now I am able to have two
selects linked, but what I need is to have a table of selects linked. I attach my xsl code, as
you will see when you change one of the selects in the first column it changes
the selectable values of all the selects in the seconds columns. The problem is in this
expression: <xforms:itemset
nodeset="instance('groups')/group[id =
(instance('selects')/tabsel[index('i_event')]/selA)]/subgroups/subgroup"> I don’t know why it
doesn’t work. **************************************
XSL CODE******************************************** <xhtml:html
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"> <xhtml:head> <xhtml:title>2
Selects</xhtml:title> <!--link
href="styles.css" rel="stylesheet"
type="text/css"/--> <xforms:model
id="main-model"> <!--
This instance contains the list of documents to display --> <xforms:instance
id="groups"> <groups> <group> <name>Group1</name> <id>1</id> <subgroups> <subgroup> <name>Sub1.1</name> <id>1</id> </subgroup> <subgroup> <name>Sub1.2</name> <id>2</id> </subgroup> </subgroups> </group> <group> <name>Group2</name> <id>2</id> <subgroups> <subgroup> <name>Sub2.1</name> <id>1</id> </subgroup> <subgroup> <name>Sub2.2</name> <id>2</id> </subgroup> <subgroup> <name>Sub2.3</name> <id>3</id> </subgroup> </subgroups> </group> </groups> </xforms:instance> <xforms:instance
id="selects"> <selects
xmlns=""> <tabsel> <selA>1</selA> <selB>1</selB> </tabsel> <tabsel> <selA>1</selA> <selB>1</selB> </tabsel> <tabsel> <selA>1</selA> <selB>1</selB> </tabsel> </selects> </xforms:instance> <xforms:submission
action="/tmg-epg/dbg" id="dbg-submission"
method="post" ref="instance('selects')"/> </xforms:model> </xhtml:head> <xhtml:body> <xforms:group
ref="instance('selects')"> <br/> <xhtml:table
class="gridtable" width="750"> <xhtml:tr> <xhtml:th>Tipo</xhtml:th> <xhtml:th>Tipo2</xhtml:th> </xhtml:tr> <xforms:repeat
nodeset="tabsel" id="i_event"> <xhtml:tr> <xhtml:td> <xforms:select1
appearance="minimal" ref="selA"> <xforms:itemset
nodeset="instance('groups')/group"> <xforms:label
ref="name"></xforms:label> <xforms:value
ref="id"></xforms:value> </xforms:itemset> </xforms:select1> </xhtml:td> <xhtml:td> <xforms:select1
appearance="minimal" ref="selB"> <xforms:itemset
nodeset="instance('groups')/group[id =
(instance('selects')/tabsel[index('i_event')]/selA)]/subgroups/subgroup"> <xforms:label
ref="name"></xforms:label> & |
Jordi,
I am struggling with an similar sort of problem myself. If I can work it out, I'll be sure to email this list. In the meantime, I would suggest you break the complex xpath expression into its constituent parts, and try to output using xforms:output. That should tell you what part of the expression is not returning the correct value: <xforms:itemset nodeset="instance('groups')/group[id = (instance('selects')/tabsel[index('i_event')]/selA)]/subgroups/subgroup"> could become: <xforms:output ref="instance('groups')/group/id"/> <xforms:output ref="instance('selects')/tabsel[index('i_event')]/selA)"/> <xforms:output ref="index('i_event')"/> What's the result of this? Also, could you send a working example of the code (just mock up the data if you need to), attached to the email? That would help me analyze the problem . I will also email this list with my particular problem (and the solution when I find it) - Perhaps this will prove helpfulll to you, too :-) Henrik On 8/27/06, Jordi Amatller <[hidden email]> wrote: > > > > > > Thanks Henrik for your ideas that helped me to understand better xforms. > > Now I am able to have two selects linked, but what I need is to have a table of selects linked. > > I attach my xsl code, as you will see when you change one of the selects in the first column it changes the selectable values of all the selects in the seconds columns. > > The problem is in this expression: > > <xforms:itemset nodeset="instance('groups')/group[id = (instance('selects')/tabsel[index('i_event')]/selA)]/subgroups/subgroup"> > > I don't know why it doesn't work. > > > > ************************************** XSL CODE******************************************** > > > > <xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:ev="http://www.w3.org/2001/xml-events" > > xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"> > > > > <xhtml:head> > > <xhtml:title>2 Selects</xhtml:title> > > > > <!--link href="styles.css" rel="stylesheet" type="text/css"/--> > > > > <xforms:model id="main-model"> > > > > <!-- This instance contains the list of documents to display --> > > <xforms:instance id="groups"> > > <groups> > > > > <group> > > <name>Group1</name> > > <id>1</id> > > <subgroups> > > <subgroup> > > <name>Sub1.1</name> > > <id>1</id> > > </subgroup> > > <subgroup> > > <name>Sub1.2</name> > > <id>2</id> > > </subgroup> > > </subgroups> > > </group> > > > > <group> > > <name>Group2</name> > > <id>2</id> > > <subgroups> > > <subgroup> > > <name>Sub2.1</name> > > <id>1</id> > > </subgroup> > > <subgroup> > > <name>Sub2.2</name> > > <id>2</id> > > </subgroup> > > <subgroup> > > <name>Sub2.3</name> > > <id>3</id> > > </subgroup> > > </subgroups> > > </group> > > </groups> > > </xforms:instance> > > > > <xforms:instance id="selects"> > > <selects xmlns=""> > > <tabsel> > > <selA>1</selA> > > <selB>1</selB> > > </tabsel> > > <tabsel> > > <selA>1</selA> > > <selB>1</selB> > > </tabsel> > > <tabsel> > > <selA>1</selA> > > <selB>1</selB> > > </tabsel> > > </selects> > > </xforms:instance> > > > > <xforms:submission action="/tmg-epg/dbg" id="dbg-submission" method="post" ref="instance('selects')"/> > > </xforms:model> > > </xhtml:head> > > > > <xhtml:body> > > > > <xforms:group ref="instance('selects')"> > > > > <br/> > > > > <xhtml:table class="gridtable" width="750"> > > <xhtml:tr> > > <xhtml:th>Tipo</xhtml:th> > > <xhtml:th>Tipo2</xhtml:th> > > </xhtml:tr> > > > > <xforms:repeat nodeset="tabsel" id="i_event"> > > <xhtml:tr> > > > > <xhtml:td> > > <xforms:select1 appearance="minimal" ref="selA"> > > <xforms:itemset nodeset="instance('groups')/group"> > > > <xforms:label ref="name"></xforms:label> > > <xforms:value ref="id"></xforms:value> > > </xforms:itemset> > > </xforms:select1> > > </xhtml:td> > > > <xhtml:td> > > <xforms:select1 appearance="minimal" ref="selB"> > > <xforms:itemset nodeset="instance('groups')/group[id = (instance('selects')/tabsel[index('i_event')]/selA)]/subgroups/subgroup"> > > > <xforms:label ref="name"></xforms:label> > > <xforms:value ref="id"></xforms:value> > > </xforms:itemset> > > </xforms:select1> > > </xhtml:td> > > </xhtml:tr> > > > </xforms:repeat> > > > > </xhtml:table> > > > > <xforms:trigger> > > <xforms:label>View XML</xforms:label> > > > <xforms:action ev:event="DOMActivate"> > > > <xforms:send submission="dbg-submission"/> > > </xforms:action> > > </xforms:trigger> > > > > </xforms:group> > > </xhtml:body> > > </xhtml:html> > > > > > > Thanks, > > Jordi > > > > > > -- > 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 > ObjectWeb mailing lists service home page: http://www.objectweb.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 ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Jordi,
when debugging xforms, you might find it helpfull to uncomment these lines in resources/config/log4j.xml: <category name="org.orbeon.oxf.xforms.processor.XFormsServer"> <priority value="debug"/> </category> to enable more logging in tomcat. Henrik On 8/27/06, Henrik Pettersen <[hidden email]> wrote: > Jordi, > > I am struggling with an similar sort of problem myself. If I can work > it out, I'll be sure to email this list. In the meantime, I would > suggest you break the complex xpath expression into its constituent > parts, and try to output using xforms:output. That should tell you > what part of the expression is not returning the correct value: > > <xforms:itemset nodeset="instance('groups')/group[id = > (instance('selects')/tabsel[index('i_event')]/selA)]/subgroups/subgroup"> > > could become: > > <xforms:output ref="instance('groups')/group/id"/> > <xforms:output ref="instance('selects')/tabsel[index('i_event')]/selA)"/> > <xforms:output ref="index('i_event')"/> > > What's the result of this? Also, could you send a working example of > the code (just mock up the data if you need to), attached to the > email? That would help me analyze the problem . > > I will also email this list with my particular problem (and the > solution when I find it) - Perhaps this will prove helpfulll to you, > too :-) > > Henrik > > > > On 8/27/06, Jordi Amatller <[hidden email]> wrote: > > > > > > > > > > > > Thanks Henrik for your ideas that helped me to understand better xforms. > > > > Now I am able to have two selects linked, but what I need is to have a table of selects linked. > > > > I attach my xsl code, as you will see when you change one of the selects in the first column it changes the selectable values of all the selects in the seconds columns. > > > > The problem is in this expression: > > > > <xforms:itemset nodeset="instance('groups')/group[id = (instance('selects')/tabsel[index('i_event')]/selA)]/subgroups/subgroup"> > > > > I don't know why it doesn't work. > > > > > > > > ************************************** XSL CODE******************************************** > > > > > > > > <xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:ev="http://www.w3.org/2001/xml-events" > > > > xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"> > > > > > > > > <xhtml:head> > > > > <xhtml:title>2 Selects</xhtml:title> > > > > > > > > <!--link href="styles.css" rel="stylesheet" type="text/css"/--> > > > > > > > > <xforms:model id="main-model"> > > > > > > > > <!-- This instance contains the list of documents to display --> > > > > <xforms:instance id="groups"> > > > > <groups> > > > > > > > > <group> > > > > <name>Group1</name> > > > > <id>1</id> > > > > <subgroups> > > > > <subgroup> > > > > <name>Sub1.1</name> > > > > <id>1</id> > > > > </subgroup> > > > > <subgroup> > > > > <name>Sub1.2</name> > > > > <id>2</id> > > > > </subgroup> > > > > </subgroups> > > > > </group> > > > > > > > > <group> > > > > <name>Group2</name> > > > > <id>2</id> > > > > <subgroups> > > > > <subgroup> > > > > <name>Sub2.1</name> > > > > <id>1</id> > > > > </subgroup> > > > > <subgroup> > > > > <name>Sub2.2</name> > > > > <id>2</id> > > > > </subgroup> > > > > <subgroup> > > > > <name>Sub2.3</name> > > > > <id>3</id> > > > > </subgroup> > > > > </subgroups> > > > > </group> > > > > </groups> > > > > </xforms:instance> > > > > > > > > <xforms:instance id="selects"> > > > > <selects xmlns=""> > > > > <tabsel> > > > > <selA>1</selA> > > > > <selB>1</selB> > > > > </tabsel> > > > > <tabsel> > > > > <selA>1</selA> > > > > <selB>1</selB> > > > > </tabsel> > > > > <tabsel> > > > > <selA>1</selA> > > > > <selB>1</selB> > > > > </tabsel> > > > > </selects> > > > > </xforms:instance> > > > > > > > > <xforms:submission action="/tmg-epg/dbg" id="dbg-submission" method="post" ref="instance('selects')"/> > > > > </xforms:model> > > > > </xhtml:head> > > > > > > > > <xhtml:body> > > > > > > > > <xforms:group ref="instance('selects')"> > > > > > > > > <br/> > > > > > > > > <xhtml:table class="gridtable" width="750"> > > > > <xhtml:tr> > > > > <xhtml:th>Tipo</xhtml:th> > > > > <xhtml:th>Tipo2</xhtml:th> > > > > </xhtml:tr> > > > > > > > > <xforms:repeat nodeset="tabsel" id="i_event"> > > > > <xhtml:tr> > > > > > > > > <xhtml:td> > > > > <xforms:select1 appearance="minimal" ref="selA"> > > > > <xforms:itemset nodeset="instance('groups')/group"> > > > > > > <xforms:label ref="name"></xforms:label> > > > > <xforms:value ref="id"></xforms:value> > > > > </xforms:itemset> > > > > </xforms:select1> > > > > </xhtml:td> > > > > > > <xhtml:td> > > > > <xforms:select1 appearance="minimal" ref="selB"> > > > > <xforms:itemset nodeset="instance('groups')/group[id = (instance('selects')/tabsel[index('i_event')]/selA)]/subgroups/subgroup"> > > > > > > <xforms:label ref="name"></xforms:label> > > > > <xforms:value ref="id"></xforms:value> > > > > </xforms:itemset> > > > > </xforms:select1> > > > > </xhtml:td> > > > > </xhtml:tr> > > > > > > </xforms:repeat> > > > > > > > > </xhtml:table> > > > > > > > > <xforms:trigger> > > > > <xforms:label>View XML</xforms:label> > > > > > > <xforms:action ev:event="DOMActivate"> > > > > > > <xforms:send submission="dbg-submission"/> > > > > </xforms:action> > > > > </xforms:trigger> > > > > > > > > </xforms:group> > > > > </xhtml:body> > > > > </xhtml:html> > > > > > > > > > > > > Thanks, > > > > Jordi > > > > > > > > > > > > -- > > 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 > > ObjectWeb mailing lists service home page: http://www.objectweb.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 ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Henrik,
I have output the xpath expressions but still don't know the cause. This is the code (only 1 xsl) to reproduce the problem. Thanks, Jordi Selects.xsl: <xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"> <xhtml:head> <xhtml:title>2 Selects</xhtml:title> <!--link href="styles.css" rel="stylesheet" type="text/css"/--> <xforms:model id="main-model"> <!-- This instance contains the list of documents to display --> <xforms:instance id="groups"> <groups> <group> <name>Group1</name> <id>1</id> <subgroups> <subgroup> <name>Sub1.1</name> <id>1</id> </subgroup> <subgroup> <name>Sub1.2</name> <id>2</id> </subgroup> </subgroups> </group> <group> <name>Group2</name> <id>2</id> <subgroups> <subgroup> <name>Sub2.1</name> <id>1</id> </subgroup> <subgroup> <name>Sub2.2</name> <id>2</id> </subgroup> <subgroup> <name>Sub2.3</name> <id>3</id> </subgroup> </subgroups> </group> </groups> </xforms:instance> <xforms:instance id="selects"> <selects xmlns=""> <tabsel> <selA>1</selA> <selB>1</selB> </tabsel> <tabsel> <selA>1</selA> <selB>1</selB> </tabsel> <tabsel> <selA>1</selA> <selB>1</selB> </tabsel> </selects> </xforms:instance> <xforms:submission action="/tmg-epg/dbg" id="dbg-submission" method="post" ref="instance('selects')"/> </xforms:model> </xhtml:head> <xhtml:body> <xforms:group ref="instance('selects')"> <br/> <xhtml:table class="gridtable" width="750"> <xhtml:tr> <xhtml:th>Tipo</xhtml:th> <xhtml:th>Tipo2</xhtml:th> </xhtml:tr> <xforms:repeat nodeset="tabsel" id="i_event"> <xhtml:tr> <xhtml:td> <xforms:select1 appearance="minimal" ref="selA"> <xforms:itemset nodeset="instance('groups')/group"> <xforms:label ref="name"></xforms:label> <xforms:value ref="id"></xforms:value> </xforms:itemset> </xforms:select1> </xhtml:td> <xhtml:td> <xforms:select1 appearance="minimal" ref="selB"> <xforms:itemset nodeset="instance('groups')/group[id = (instance('selects')/tabsel[index('i_event')]/selA)]/subgroups/subgroup"> <xforms:label ref="name"></xforms:label> <xforms:value ref="id"></xforms:value> </xforms:itemset> </xforms:select1> </xhtml:td> <xhtml:td> <!--xforms:output ref="instance('groups')/group/id"/--> </xhtml:td> <xhtml:td> <xforms:output ref="instance('selects')/tabsel[index('i_event')]/selA"/> </xhtml:td> <xhtml:td> <xforms:output ref="index('i_event')"/> </xhtml:td> </xhtml:tr> </xforms:repeat> </xhtml:table> <xforms:trigger> <xforms:label>View XML</xforms:label> <xforms:action ev:event="DOMActivate"> <xforms:send submission="dbg-submission"/> </xforms:action> </xforms:trigger> </xforms:group> </xhtml:body> </xhtml:html> -- 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 ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Jordi,
could you attach the file instead of copy-pasting into email body? It screws up the indentation and adds silly line breaks everywhere. Thanks! Henrik On 8/28/06, Jordi Amatller <[hidden email]> wrote: > Henrik, > > I have output the xpath expressions but still don't know the cause. This is > the code (only 1 xsl) to reproduce the problem. > > Thanks, > Jordi > > > Selects.xsl: > > > <xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns:xforms="http://www.w3.org/2002/xforms" > xmlns:xi="http://www.w3.org/2001/XInclude" > xmlns:ev="http://www.w3.org/2001/xml-events" > xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"> > > <xhtml:head> > <xhtml:title>2 Selects</xhtml:title> > > <!--link href="styles.css" rel="stylesheet" > type="text/css"/--> > > <xforms:model id="main-model"> > > <!-- This instance contains the list of documents to > display --> > <xforms:instance id="groups"> > <groups> > > <group> > <name>Group1</name> > <id>1</id> > <subgroups> > <subgroup> > > <name>Sub1.1</name> > <id>1</id> > </subgroup> > <subgroup> > > <name>Sub1.2</name> > <id>2</id> > </subgroup> > </subgroups> > </group> > > <group> > <name>Group2</name> > <id>2</id> > <subgroups> > <subgroup> > > <name>Sub2.1</name> > <id>1</id> > </subgroup> > <subgroup> > > <name>Sub2.2</name> > <id>2</id> > </subgroup> > <subgroup> > > <name>Sub2.3</name> > <id>3</id> > </subgroup> > </subgroups> > </group> > </groups> > </xforms:instance> > > <xforms:instance id="selects"> > <selects xmlns=""> > <tabsel> > <selA>1</selA> > <selB>1</selB> > </tabsel> > <tabsel> > <selA>1</selA> > <selB>1</selB> > </tabsel> > <tabsel> > <selA>1</selA> > <selB>1</selB> > </tabsel> > </selects> > </xforms:instance> > > <xforms:submission action="/tmg-epg/dbg" > id="dbg-submission" method="post" ref="instance('selects')"/> > </xforms:model> > </xhtml:head> > > <xhtml:body> > > <xforms:group ref="instance('selects')"> > > <br/> > > <xhtml:table class="gridtable" width="750"> > <xhtml:tr> > <xhtml:th>Tipo</xhtml:th> > <xhtml:th>Tipo2</xhtml:th> > </xhtml:tr> > > <xforms:repeat nodeset="tabsel" > id="i_event"> > <xhtml:tr> > > <xhtml:td> > <xforms:select1 > appearance="minimal" ref="selA"> > > <xforms:itemset nodeset="instance('groups')/group"> > > <xforms:label ref="name"></xforms:label> > > <xforms:value ref="id"></xforms:value> > > </xforms:itemset> > </xforms:select1> > </xhtml:td> > <xhtml:td> > <xforms:select1 > appearance="minimal" ref="selB"> > <xforms:itemset > nodeset="instance('groups')/group[id = > (instance('selects')/tabsel[index('i_event')]/selA)]/subgroups/subgroup"> > > <xforms:label ref="name"></xforms:label> > > <xforms:value ref="id"></xforms:value> > </xforms:itemset> > </xforms:select1> > </xhtml:td> > <xhtml:td> > <!--xforms:output > ref="instance('groups')/group/id"/--> > </xhtml:td> > <xhtml:td> > <xforms:output > ref="instance('selects')/tabsel[index('i_event')]/selA"/> > </xhtml:td> > <xhtml:td> > <xforms:output > ref="index('i_event')"/> > </xhtml:td> > > </xhtml:tr> > </xforms:repeat> > > </xhtml:table> > > <xforms:trigger> > <xforms:label>View XML</xforms:label> > <xforms:action ev:event="DOMActivate"> > <xforms:send > submission="dbg-submission"/> > </xforms:action> > </xforms:trigger> > > </xforms:group> > </xhtml:body> > </xhtml:html> > > > > > > -- > 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 > ObjectWeb mailing lists service home page: http://www.objectweb.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 ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
In reply to this post by Henrik Pettersen
Ah, yes. I finally got it to work!
I have attached the code in case anyone is interested: My problem was that I wanted a select action to copy a small xml fragment to a new instance, and not just a single value ( i.e. <xforms:value ref="aspic:id"/> was not sufficient). So inside my select: <xforms:select1 ref="aspic:knowledgebase/aspic:id" appearance="minimal" id="select-knowledgebase"> <xforms:itemset nodeset="instance('initial')/aspic:knowledgebase"> <xforms:label ref="aspic:name"/> <xforms:value ref="aspic:id"/> </xforms:itemset> ...... {action goes here} ..... </xforms:select1> I added an action to copy each element of this xml fragment to my new instance: <xforms:action ev:event="xforms-value-changed"> <xforms:setvalue ref= "instance('selection')/aspic:selection[index('queries-repeat')]/ aspic:knowledgebase/aspic:name" value="instance('initial')/aspic:knowledgebase[aspic:id= instance('selection')/aspic:selection[index('queries-repeat')]/ aspic:knowledgebase/aspic:id]/aspic:name"/> .... </xforms:action> Notice the very long xpath expressions! Check out the code for more in-depth details (it's self-contained and runnable). Hope this helps, Jordi! Henrik On 8/27/06, Henrik Pettersen < [hidden email]> wrote: > Jordi, > > I am struggling with an similar sort of problem myself. If I can work > it out, I'll be sure to email this list. In the meantime, I would > suggest you break the complex xpath expression into its constituent > parts, and try to output using xforms:output. That should tell you > what part of the expression is not returning the correct value: > > <xforms:itemset nodeset="instance('groups')/group[id = > (instance('selects')/tabsel[index('i_event')]/selA)]/subgroups/subgroup"> > > could become: > > <xforms:output ref="instance('groups')/group/id"/> > <xforms:output ref="instance('selects')/tabsel[index('i_event')]/selA)"/> > <xforms:output ref="index('i_event')"/> > > What's the result of this? Also, could you send a working example of > the code (just mock up the data if you need to), attached to the > email? That would help me analyze the problem . > > I will also email this list with my particular problem (and the > solution when I find it) - Perhaps this will prove helpfulll to you, > too :-) > > Henrik > > > > On 8/27/06, Jordi Amatller <[hidden email]> wrote: > > > > > > > > > > Thanks Henrik for your ideas that helped me to understand better xforms. > > > > Now I am able to have two selects linked, but what I need is to have a table of selects linked. > > > > I attach my xsl code, as you will see when you change one of the selects in the first column it changes the selectable values of all the selects in the seconds columns. > > > > The problem is in this expression: > > > > <xforms:itemset nodeset="instance('groups')/group[id = (instance('selects')/tabsel[index('i_event')]/selA)]/subgroups/subgroup"> > > > > I don't know why it doesn't work. > > > > > > > > ************************************** XSL CODE******************************************** > > > > > > > > <xhtml:html xmlns:xhtml=" http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xforms=" http://www.w3.org/2002/xforms" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:ev="http://www.w3.org/2001/xml-events " > > > > xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"> > > > > > > > > <xhtml:head> > > > > <xhtml:title>2 Selects</xhtml:title> > > > > > > > > <!--link href="styles.css" rel="stylesheet" type="text/css"/--> > > > > > > > > <xforms:model id="main-model"> > > > > > > > > <!-- This instance contains the list of documents to display --> > > > > <xforms:instance id="groups"> > > > > <groups> > > > > > > > > <group> > > > > <name>Group1</name> > > > > <id>1</id> > > > > <subgroups> > > > > <subgroup> > > > > <name> Sub1.1</name> > > > > <id>1</id> > > > > </subgroup> > > > > <subgroup> > > > > <name> Sub1.2</name> > > > > <id>2</id> > > > > </subgroup> > > > > </subgroups> > > > > </group> > > > > > > > > <group> > > > > <name>Group2</name> > > > > <id>2</id> > > > > <subgroups> > > > > <subgroup> > > > > <name> Sub2.1</name> > > > > <id>1</id> > > > > </subgroup> > > > > <subgroup> > > > > <name> Sub2.2</name> > > > > <id>2</id> > > > > </subgroup> > > > > <subgroup> > > > > <name> Sub2.3</name> > > > > <id>3</id> > > > > </subgroup> > > > > </subgroups> > > > > </group> > > > > </groups> > > > > </xforms:instance> > > > > > > > > <xforms:instance id="selects"> > > > > <selects xmlns=""> > > > > <tabsel> > > > > <selA>1</selA> > > > > <selB>1</selB> > > > > </tabsel> > > > > <tabsel> > > > > <selA>1</selA> > > > > <selB>1</selB> > > > > </tabsel> > > > > <tabsel> > > > > <selA>1</selA> > > > > <selB>1</selB> > > > > </tabsel> > > > > </selects> > > > > </xforms:instance> > > > > > > > > <xforms:submission action="/tmg-epg/dbg" id="dbg-submission" method="post" ref="instance('selects')"/> > > > > </xforms:model> > > > > </xhtml:head> > > > > > > > > <xhtml:body> > > > > > > > > <xforms:group ref="instance('selects')"> > > > > > > > > <br/> > > > > > > <xhtml:table class="gridtable" width="750"> > > > > <xhtml:tr> > > > > <xhtml:th>Tipo</xhtml:th> > > > > <xhtml:th>Tipo2</xhtml:th> > > > > </xhtml:tr> > > > > > > > > <xforms:repeat nodeset="tabsel" id="i_event"> > > > > <xhtml:tr> > > > > > > > > <xhtml:td> > > > > <xforms:select1 appearance="minimal" ref="selA"> > > > > <xforms:itemset nodeset="instance('groups')/group"> > > > > > > <xforms:label ref="name"></xforms:label> > > > > <xforms:value ref="id"></xforms:value> > > > > </xforms:itemset> > > > > </xforms:select1> > > > > </xhtml:td> > > > > > > <xhtml:td> > > > > <xforms:select1 appearance="minimal" ref="selB"> > > > > <xforms:itemset nodeset="instance('groups')/group[id = (instance('selects')/tabsel[index('i_event')]/selA)]/subgroups/subgroup"> > > > > > > <xforms:label ref="name"></xforms:label> > > > > <xforms:value ref="id"></xforms:value> > > > > </xforms:itemset> > > > > </xforms:select1> > > > > </xhtml:td> > > > > </xhtml:tr> > > > > </xforms:repeat> > > > > > > > > </xhtml:table> > > > > > > > > <xforms:trigger> > > > > <xforms:label>View XML</xforms:label> > > > > <xforms:action ev:event="DOMActivate"> > > > > > > <xforms:send submission="dbg-submission"/> > > > > </xforms:action> > > > > </xforms:trigger> > > > > > > > > > > </xhtml:body> > > > > </xhtml:html> > > > > > > > > > > > > Thanks, > > > > Jordi > > > > > > > > > > > > -- > > 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 > > ObjectWeb mailing lists service home page: http://www.objectweb.org/wws > > > > > > > |
Hi Henrik, good you
finally resolved your problem. I also solved my problem
thanks to your suggestions for debugging xforms. The point was to use xxforms:repeat-current('i_event')/selA
to get the current row selection. I attached the complete
working code with several rows of linked selects. I haven’t used <xforms:action ev:event="xforms-value-changed"> but
is good to know for the future Best regards, Jordi -- 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 ObjectWeb mailing lists service home page: http://www.objectweb.org/wws selects.xsl (3K) Download Attachment |
Excellent!
Yes, xxforms:context('repeat-id') and element[index('repeat-id')] should be interchangable, with the prior being a much more terse (and perhaps favorable) syntax. It can also be usefull to pay attention to all the events that are generated when you load and interact with a page: Look out for triggering of these events in the debug output (That's where I found xforms-value-changed). Henrik On 8/28/06, Jordi Amatller <[hidden email]> wrote:
-- 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 ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Free forum by Nabble | Edit this page |