Hi,
First of all, many thanks to those that have helped me so far.. My problem today probably has an easy solution, but I can't see it. I have one instance that is being used to collect the data, and another that I just want to use to provide a bit of context sensitive feedback with. The form is almost extensively range control based. Every range has values 1-5. The second instance has 5 'competences'. If a range control is moved so that its value is 2, I want to display the value of the 2nd 'competence'. The structure of the first instance is: <questionnaires> <questionnaire name="elearningskillschecklist"> <group> <q text="fddsadsadsad"/> <q text="fddsadsadsad"/> <q text="fddsadsadsad"/> </group> .... .... </questionnaire> </questionnaires> The structure of the second instance is: <competences> <competence> ... ... </competences> Within the form I have range controls set up like this: <xforms:range ref="q[2]" start="1" end="5" step="1"> <xforms:hint> <xforms:output value="instance('competence-instance')/competence[q[2]]"/> </xforms:hint> </xforms:range> As you can see, what I am trying to do is have the competence in the position that has been chosen by the control printed as the hint. If I use output value="instance('competence-instance')/competence[2]" for example, I get the value of the 2nd competence. If I use output value="q[2]" I get the value of the range control (an xs:integer). So why doesn't .... /competence[q[2]] work? This seems the logical way of doing what I need to do. Can someone put me straight please? Many thanks, Paul Saxelby -- 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 |
Let's see if I can come up with a clear wording of this.
The problem with your XPath expression "instance('competence-instance')/competence[q[2]]" is that the predicate "q[2]" gets evaluated in the context of the competence node, not the original context where "q[2]" made sense. To paraphrase, it says "take the top level element of the 'competence-instance' instance, and then take each child node which is called competence and which has the property that it has a child node called q with position 2 (i.e. it has at least two children called q)".
Well, that's obviously not what you want, so the question is how best to get what you do want. Others will no doubt have better ideas, but one thing you could try is "for $i in . return instance('competence-instance')/competence[$i]". That's a strange use of a "for" loop which is a useful trick for setting a variable in an XPath expression and then referring to it.
Hope this helps,
Dave Mc
>>> "Paul Saxelby" <[hidden email]> 22/06/2007 11:21 a.m. >>> Hi, First of all, many thanks to those that have helped me so far.. My problem today probably has an easy solution, but I can't see it. I have one instance that is being used to collect the data, and another that I just want to use to provide a bit of context sensitive feedback with. The form is almost extensively range control based. Every range has values 1-5. The second instance has 5 'competences'. If a range control is moved so that its value is 2, I want to display the value of the 2nd 'competence'. The structure of the first instance is: <questionnaires> <questionnaire name="elearningskillschecklist"> <group> <q text="fddsadsadsad"/> <q text="fddsadsadsad"/> <q text="fddsadsadsad"/> </group> .... .... </questionnaire> </questionnaires> The structure of the second instance is: <competences> <competence> ... ... </competences> Within the form I have range controls set up like this: <xforms:range ref="q[2]" start="1" end="5" step="1"> <xforms:hint> <xforms:output value="instance('competence-instance')/competence[q[2]]"/> </xforms:hint> </xforms:range> As you can see, what I am trying to do is have the competence in the position that has been chosen by the control printed as the hint. If I use output value="instance('competence-instance')/competence[2]" for example, I get the value of the 2nd competence. If I use output value="q[2]" I get the value of the range control (an xs:integer). So why doesn't .... /competence[q[2]] work? This seems the logical way of doing what I need to do. Can someone put me straight please? Many thanks, Paul Saxelby -- 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 Dave,
Many thanks - The problem with competence[q[2]] is obvious when you look at it from the right angle :/ I have tried your $i suggestion, as in: <xforms:range ref="q[2]" start="1" end="5" step="1"> <xforms:hint> <xforms:output value="for $i in . return instance('competence-instance')/competence[$i]"/> </xforms:hint> </xforms:range> I think that the '.' refers to the current node in scope, which I think is q[2] from the ref attribute. It does result in one of the competence values being displayed, but it's always the first one, and it doesn't change when the slider is moved. To see if it was to do with the initial value of the q[2] node I set it to 3, and now I'm doubley confused. As the control is (hopefully) bound to the node with: <xforms:bind nodeset="questionnaire"> ... <xforms:bind nodeset="Group[2]/q[2]" type="xs:integer" required="true()"/> ... I had assumed that when the page opened the control would be in position 3 as it should reflect the value in the instance (shouldn't it?). Any further info would be greatly appreciated. Regards, Paul On 22/06/07, David McIntyre <[hidden email]> wrote: > > > Let's see if I can come up with a clear wording of this. > > The problem with your XPath expression "instance('competence-instance')/competence[q[2]]" is that the predicate "q[2]" gets evaluated in the context of the competence node, not the original context where "q[2]" made sense. To paraphrase, it says "take the top level element of the 'competence-instance' instance, and then take each child node which is called competence and which has the property that it has a child node called q with position 2 (i.e. it has at least two children called q)". > > Well, that's obviously not what you want, so the question is how best to get what you do want. Others will no doubt have better ideas, but one thing you could try is "for $i in . return instance('competence-instance')/competence[$i]". That's a strange use of a "for" loop which is a useful trick for setting a variable in an XPath expression and then referring to it. > > Hope this helps, > > Dave Mc > > > > > > > > Dave McIntyre MA, DPhil, GradDipSci > Software Developer > [hidden email] > P: +64 9 638 0600 > F: +64 9 638 0699 > M: +64 21 212 8087 > S: dave.mcintyre > www.orionhealth.com > > >>> "Paul Saxelby" <[hidden email]> 22/06/2007 11:21 a.m. >>> > > Hi, > First of all, many thanks to those that have helped me so far.. > > My problem today probably has an easy solution, but I can't see it. > > I have one instance that is being used to collect the data, and > another that I just want to use to provide a bit of context sensitive > feedback with. > The form is almost extensively range control based. Every range has > values 1-5. The second instance has 5 'competences'. > If a range control is moved so that its value is 2, I want to display > the value of the 2nd 'competence'. > > The structure of the first instance is: > <questionnaires> > <questionnaire name="elearningskillschecklist"> > <group> > <q text="fddsadsadsad"/> > <q text="fddsadsadsad"/> > <q text="fddsadsadsad"/> > </group> > .... > .... > </questionnaire> > </questionnaires> > > The structure of the second instance is: > <competences> > <competence> > ... > ... > </competences> > > Within the form I have range controls set up like this: > > <xforms:range ref="q[2]" start="1" end="5" step="1"> > <xforms:hint> > <xforms:output value="instance('competence-instance')/competence[q[2]]"/> > </xforms:hint> > </xforms:range> > > As you can see, what I am trying to do is have the competence in the > position that has been chosen by the control printed as the hint. > > If I use output > value="instance('competence-instance')/competence[2]" for example, > I get the value of the 2nd competence. > If I use output value="q[2]" I get the value of the range > control (an xs:integer). > > So why doesn't .... /competence[q[2]] work? > This seems the logical way of doing what I need to do. > Can someone put me straight please? > > > Many thanks, > Paul Saxelby > > > > -- > 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 |
What about something along the lines of:
instance('competence-instance')/competence[position() = instance('questionnaires-instance')//q[2]] I'm sure there is a better way for you to select //q[2] but that would largely depend on what you have around this construct. For instance, you probably could use index() to help you select the proper <q/> but I'm assuming you've just dropped that for your example. -- Daniel E. Renfer http://kronkltd.net/ On 6/21/07, Paul Saxelby <[hidden email]> wrote: Hi Dave, -- 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 |
Perhaps your problem is the predicate. You want to use the predicate to indicate position in the nodeset.
node[3] is shorthand for node[position() = 3] So when you put competence[q[2]], the xforms engine is evalutaing q[2] as a boolean, true, so the first node is used. Trying casting it as a number: <xforms:output value="instance('competence-instance')/competence[number(q[2])]"/> or <xforms:output value="instance('competence-instance')/competence[position() = q[2]]"/>
|
Administrator
|
In reply to this post by Paul Saxelby
Paul,
Can you provide an XHTML+XForms file which runs in the sandbox and shows the latest problem? -Erik Paul Saxelby wrote: > Hi Dave, > > Many thanks - The problem with competence[q[2]] is obvious when you > look at it from the right angle :/ > > > I have tried your $i suggestion, as in: > > <xforms:range ref="q[2]" start="1" end="5" step="1"> > <xforms:hint> > <xforms:output value="for $i in . return > instance('competence-instance')/competence[$i]"/> > </xforms:hint> > </xforms:range> > > I think that the '.' refers to the current node in scope, which I > think is q[2] from the ref attribute. > > It does result in one of the competence values being displayed, but > it's always the first one, and it doesn't change when the slider is > moved. > To see if it was to do with the initial value of the q[2] node I set > it to 3, and now I'm doubley confused. > As the control is (hopefully) bound to the node with: > > <xforms:bind nodeset="questionnaire"> > ... > <xforms:bind nodeset="Group[2]/q[2]" type="xs:integer" required="true()"/> > ... > > I had assumed that when the page opened the control would be in > position 3 as it should reflect the value in the instance (shouldn't > it?). > > > Any further info would be greatly appreciated. > > Regards, > Paul > > > On 22/06/07, David McIntyre <[hidden email]> wrote: >> >> >> Let's see if I can come up with a clear wording of this. >> >> The problem with your XPath expression >> "instance('competence-instance')/competence[q[2]]" is that the >> predicate "q[2]" gets evaluated in the context of the competence node, >> not the original context where "q[2]" made sense. To paraphrase, it >> says "take the top level element of the 'competence-instance' >> instance, and then take each child node which is called competence and >> which has the property that it has a child node called q with position >> 2 (i.e. it has at least two children called q)". >> >> Well, that's obviously not what you want, so the question is how best >> to get what you do want. Others will no doubt have better ideas, but >> one thing you could try is "for $i in . return >> instance('competence-instance')/competence[$i]". That's a strange use >> of a "for" loop which is a useful trick for setting a variable in an >> XPath expression and then referring to it. >> >> Hope this helps, >> >> Dave Mc >> >> >> >> >> >> >> >> Dave McIntyre MA, DPhil, GradDipSci >> Software Developer >> [hidden email] >> P: +64 9 638 0600 >> F: +64 9 638 0699 >> M: +64 21 212 8087 >> S: dave.mcintyre >> www.orionhealth.com >> >> >>> "Paul Saxelby" <[hidden email]> 22/06/2007 11:21 a.m. >>> >> >> Hi, >> First of all, many thanks to those that have helped me so far.. >> >> My problem today probably has an easy solution, but I can't see it. >> >> I have one instance that is being used to collect the data, and >> another that I just want to use to provide a bit of context sensitive >> feedback with. >> The form is almost extensively range control based. Every range has >> values 1-5. The second instance has 5 'competences'. >> If a range control is moved so that its value is 2, I want to display >> the value of the 2nd 'competence'. >> >> The structure of the first instance is: >> <questionnaires> >> <questionnaire name="elearningskillschecklist"> >> <group> >> <q text="fddsadsadsad"/> >> <q text="fddsadsadsad"/> >> <q text="fddsadsadsad"/> >> </group> >> .... >> .... >> </questionnaire> >> </questionnaires> >> >> The structure of the second instance is: >> <competences> >> <competence> >> ... >> ... >> </competences> >> >> Within the form I have range controls set up like this: >> >> <xforms:range ref="q[2]" start="1" end="5" step="1"> >> <xforms:hint> >> <xforms:output >> value="instance('competence-instance')/competence[q[2]]"/> >> </xforms:hint> >> </xforms:range> >> >> As you can see, what I am trying to do is have the competence in the >> position that has been chosen by the control printed as the hint. >> >> If I use output >> value="instance('competence-instance')/competence[2]" for example, >> I get the value of the 2nd competence. >> If I use output value="q[2]" I get the value of the range >> control (an xs:integer). >> >> So why doesn't .... /competence[q[2]] work? >> This seems the logical way of doing what I need to do. >> Can someone put me straight please? >> >> >> Many thanks, >> Paul Saxelby >> >> >> >> -- >> 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 >> >> > -- Orbeon Forms - Web Forms for the Enterprise Done the Right Way http://www.orbeon.com/ -- 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 Erik,
Many thanks for the help. I think that I'm just making a really dumb beginner's mistake (or 5) in my XForms code/setup. I'm afraid that another thing I don't know is the requirements for running in the sandbox (apart from not carrying scissors ;) ). I've attached the view.xhtml file, the output from which'll look a tad strange without the little bit of css laying it out, & without the new pngs for the range control. (If nothing else it might provide a few chuckles ;) If anything else is needed to let it run in the sandbox just let me know & I'll get it ready. Many thanks to you & anyone else that can let me know what I'm doing wrong. Best regards Erik, Paul. On 22/06/07, Erik Bruchez <[hidden email]> wrote: > Paul, > > Can you provide an XHTML+XForms file which runs in the sandbox and shows > the latest problem? > > -Erik > > Paul Saxelby wrote: > > Hi Dave, > > > > Many thanks - The problem with competence[q[2]] is obvious when you > > look at it from the right angle :/ > > > > > > I have tried your $i suggestion, as in: > > > > <xforms:range ref="q[2]" start="1" end="5" step="1"> > > <xforms:hint> > > <xforms:output value="for $i in . return > > instance('competence-instance')/competence[$i]"/> > > </xforms:hint> > > </xforms:range> > > > > I think that the '.' refers to the current node in scope, which I > > think is q[2] from the ref attribute. > > > > It does result in one of the competence values being displayed, but > > it's always the first one, and it doesn't change when the slider is > > moved. > > To see if it was to do with the initial value of the q[2] node I set > > it to 3, and now I'm doubley confused. > > As the control is (hopefully) bound to the node with: > > > > <xforms:bind nodeset="questionnaire"> > > ... > > <xforms:bind nodeset="Group[2]/q[2]" type="xs:integer" required="true()"/> > > ... > > > > I had assumed that when the page opened the control would be in > > position 3 as it should reflect the value in the instance (shouldn't > > it?). > > > > > > Any further info would be greatly appreciated. > > > > Regards, > > Paul > > > > > > On 22/06/07, David McIntyre <[hidden email]> wrote: > >> > >> > >> Let's see if I can come up with a clear wording of this. > >> > >> The problem with your XPath expression > >> "instance('competence-instance')/competence[q[2]]" is that the > >> predicate "q[2]" gets evaluated in the context of the competence node, > >> not the original context where "q[2]" made sense. To paraphrase, it > >> says "take the top level element of the 'competence-instance' > >> instance, and then take each child node which is called competence and > >> which has the property that it has a child node called q with position > >> 2 (i.e. it has at least two children called q)". > >> > >> Well, that's obviously not what you want, so the question is how best > >> to get what you do want. Others will no doubt have better ideas, but > >> one thing you could try is "for $i in . return > >> instance('competence-instance')/competence[$i]". That's a strange use > >> of a "for" loop which is a useful trick for setting a variable in an > >> XPath expression and then referring to it. > >> > >> Hope this helps, > >> > >> Dave Mc > >> > >> > >> > >> > >> > >> > >> > >> Dave McIntyre MA, DPhil, GradDipSci > >> Software Developer > >> [hidden email] > >> P: +64 9 638 0600 > >> F: +64 9 638 0699 > >> M: +64 21 212 8087 > >> S: dave.mcintyre > >> www.orionhealth.com > >> > >> >>> "Paul Saxelby" <[hidden email]> 22/06/2007 11:21 a.m. >>> > >> > >> Hi, > >> First of all, many thanks to those that have helped me so far.. > >> > >> My problem today probably has an easy solution, but I can't see it. > >> > >> I have one instance that is being used to collect the data, and > >> another that I just want to use to provide a bit of context sensitive > >> feedback with. > >> The form is almost extensively range control based. Every range has > >> values 1-5. The second instance has 5 'competences'. > >> If a range control is moved so that its value is 2, I want to display > >> the value of the 2nd 'competence'. > >> > >> The structure of the first instance is: > >> <questionnaires> > >> <questionnaire name="elearningskillschecklist"> > >> <group> > >> <q text="fddsadsadsad"/> > >> <q text="fddsadsadsad"/> > >> <q text="fddsadsadsad"/> > >> </group> > >> .... > >> .... > >> </questionnaire> > >> </questionnaires> > >> > >> The structure of the second instance is: > >> <competences> > >> <competence> > >> ... > >> ... > >> </competences> > >> > >> Within the form I have range controls set up like this: > >> > >> <xforms:range ref="q[2]" start="1" end="5" step="1"> > >> <xforms:hint> > >> <xforms:output > >> value="instance('competence-instance')/competence[q[2]]"/> > >> </xforms:hint> > >> </xforms:range> > >> > >> As you can see, what I am trying to do is have the competence in the > >> position that has been chosen by the control printed as the hint. > >> > >> If I use output > >> value="instance('competence-instance')/competence[2]" for example, > >> I get the value of the 2nd competence. > >> If I use output value="q[2]" I get the value of the range > >> control (an xs:integer). > >> > >> So why doesn't .... /competence[q[2]] work? > >> This seems the logical way of doing what I need to do. > >> Can someone put me straight please? > >> > >> > >> Many thanks, > >> Paul Saxelby > >> > >> > >> > >> -- > >> 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 > >> > >> > > > > > -- > Orbeon Forms - Web Forms for the Enterprise Done the Right Way > http://www.orbeon.com/ > > > > -- > 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 view.xhtml (12K) Download Attachment |
Hi Erik,
Just a little update. I ran the file in the sandbox (err... that was easy). The only difference between the output there and the output I get here is that the two nodes that I've set a value for don't have the little error exclamation, although the range slider still isn't showing the value they're set to. (I'm assuming it should be...). Regards, Paul On 23/06/07, Paul Saxelby <[hidden email]> wrote: > Hi Erik, > > Many thanks for the help. I think that I'm just making a really dumb > beginner's mistake (or 5) in my XForms code/setup. > > I'm afraid that another thing I don't know is the requirements for > running in the sandbox (apart from not carrying scissors ;) ). > > I've attached the view.xhtml file, the output from which'll look a tad > strange without the little bit of css laying it out, & without the new > pngs for the range control. > (If nothing else it might provide a few chuckles ;) > > If anything else is needed to let it run in the sandbox just let me > know & I'll get it ready. > > Many thanks to you & anyone else that can let me know what I'm doing wrong. > > Best regards Erik, > > Paul. > > On 22/06/07, Erik Bruchez <[hidden email]> wrote: > > Paul, > > > > Can you provide an XHTML+XForms file which runs in the sandbox and shows > > the latest problem? > > > > -Erik > > > > Paul Saxelby wrote: > > > Hi Dave, > > > > > > Many thanks - The problem with competence[q[2]] is obvious when you > > > look at it from the right angle :/ > > > > > > > > > I have tried your $i suggestion, as in: > > > > > > <xforms:range ref="q[2]" start="1" end="5" step="1"> > > > <xforms:hint> > > > <xforms:output value="for $i in . return > > > instance('competence-instance')/competence[$i]"/> > > > </xforms:hint> > > > </xforms:range> > > > > > > I think that the '.' refers to the current node in scope, which I > > > think is q[2] from the ref attribute. > > > > > > It does result in one of the competence values being displayed, but > > > it's always the first one, and it doesn't change when the slider is > > > moved. > > > To see if it was to do with the initial value of the q[2] node I set > > > it to 3, and now I'm doubley confused. > > > As the control is (hopefully) bound to the node with: > > > > > > <xforms:bind nodeset="questionnaire"> > > > ... > > > <xforms:bind nodeset="Group[2]/q[2]" type="xs:integer" required="true()"/> > > > ... > > > > > > I had assumed that when the page opened the control would be in > > > position 3 as it should reflect the value in the instance (shouldn't > > > it?). > > > > > > > > > Any further info would be greatly appreciated. > > > > > > Regards, > > > Paul > > > > > > > > > On 22/06/07, David McIntyre <[hidden email]> wrote: > > >> > > >> > > >> Let's see if I can come up with a clear wording of this. > > >> > > >> The problem with your XPath expression > > >> "instance('competence-instance')/competence[q[2]]" is that the > > >> predicate "q[2]" gets evaluated in the context of the competence node, > > >> not the original context where "q[2]" made sense. To paraphrase, it > > >> says "take the top level element of the 'competence-instance' > > >> instance, and then take each child node which is called competence and > > >> which has the property that it has a child node called q with position > > >> 2 (i.e. it has at least two children called q)". > > >> > > >> Well, that's obviously not what you want, so the question is how best > > >> to get what you do want. Others will no doubt have better ideas, but > > >> one thing you could try is "for $i in . return > > >> instance('competence-instance')/competence[$i]". That's a strange use > > >> of a "for" loop which is a useful trick for setting a variable in an > > >> XPath expression and then referring to it. > > >> > > >> Hope this helps, > > >> > > >> Dave Mc > > >> > > >> > > >> > > >> > > >> > > >> > > >> > > >> Dave McIntyre MA, DPhil, GradDipSci > > >> Software Developer > > >> [hidden email] > > >> P: +64 9 638 0600 > > >> F: +64 9 638 0699 > > >> M: +64 21 212 8087 > > >> S: dave.mcintyre > > >> www.orionhealth.com > > >> > > >> >>> "Paul Saxelby" <[hidden email]> 22/06/2007 11:21 a.m. >>> > > >> > > >> Hi, > > >> First of all, many thanks to those that have helped me so far.. > > >> > > >> My problem today probably has an easy solution, but I can't see it. > > >> > > >> I have one instance that is being used to collect the data, and > > >> another that I just want to use to provide a bit of context sensitive > > >> feedback with. > > >> The form is almost extensively range control based. Every range has > > >> values 1-5. The second instance has 5 'competences'. > > >> If a range control is moved so that its value is 2, I want to display > > >> the value of the 2nd 'competence'. > > >> > > >> The structure of the first instance is: > > >> <questionnaires> > > >> <questionnaire name="elearningskillschecklist"> > > >> <group> > > >> <q text="fddsadsadsad"/> > > >> <q text="fddsadsadsad"/> > > >> <q text="fddsadsadsad"/> > > >> </group> > > >> .... > > >> .... > > >> </questionnaire> > > >> </questionnaires> > > >> > > >> The structure of the second instance is: > > >> <competences> > > >> <competence> > > >> ... > > >> ... > > >> </competences> > > >> > > >> Within the form I have range controls set up like this: > > >> > > >> <xforms:range ref="q[2]" start="1" end="5" step="1"> > > >> <xforms:hint> > > >> <xforms:output > > >> value="instance('competence-instance')/competence[q[2]]"/> > > >> </xforms:hint> > > >> </xforms:range> > > >> > > >> As you can see, what I am trying to do is have the competence in the > > >> position that has been chosen by the control printed as the hint. > > >> > > >> If I use output > > >> value="instance('competence-instance')/competence[2]" for example, > > >> I get the value of the 2nd competence. > > >> If I use output value="q[2]" I get the value of the range > > >> control (an xs:integer). > > >> > > >> So why doesn't .... /competence[q[2]] work? > > >> This seems the logical way of doing what I need to do. > > >> Can someone put me straight please? > > >> > > >> > > >> Many thanks, > > >> Paul Saxelby > > >> > > >> > > >> > > >> -- > > >> 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 > > >> > > >> > > > > > > > > > -- > > Orbeon Forms - Web Forms for the Enterprise Done the Right Way > > http://www.orbeon.com/ > > > > > > > > -- > > 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 |
Hi all,
Just wondering if anyone had any further info that they could give me on these problems at all? The first is that the text shown from the second instance doesn't change when the range control is moved. The second is that the range control doesn't reflect the value of the bound node that it references if the node has a value when the form loads. I really need to get past these problems - I'm running out of time & I'd really rather get to grips with XForms than drop back to perl or js... The form is attached to an earlier part of this thread. Any & all help greatly appreciated. Regards, Paul Saxelby On 23/06/07, Paul Saxelby <[hidden email]> wrote: > Hi Erik, > > Just a little update. I ran the file in the sandbox (err... that was easy). > The only difference between the output there and the output I get here > is that the two nodes that I've set a value for don't have the little > error exclamation, although the range slider still isn't showing the > value they're set to. (I'm assuming it should be...). > > Regards, > Paul > > On 23/06/07, Paul Saxelby <[hidden email]> wrote: > > Hi Erik, > > > > Many thanks for the help. I think that I'm just making a really dumb > > beginner's mistake (or 5) in my XForms code/setup. > > > > I'm afraid that another thing I don't know is the requirements for > > running in the sandbox (apart from not carrying scissors ;) ). > > > > I've attached the view.xhtml file, the output from which'll look a tad > > strange without the little bit of css laying it out, & without the new > > pngs for the range control. > > (If nothing else it might provide a few chuckles ;) > > > > If anything else is needed to let it run in the sandbox just let me > > know & I'll get it ready. > > > > Many thanks to you & anyone else that can let me know what I'm doing wrong. > > > > Best regards Erik, > > > > Paul. > > > > On 22/06/07, Erik Bruchez <[hidden email]> wrote: > > > Paul, > > > > > > Can you provide an XHTML+XForms file which runs in the sandbox and shows > > > the latest problem? > > > > > > -Erik > > > > > > Paul Saxelby wrote: > > > > Hi Dave, > > > > > > > > Many thanks - The problem with competence[q[2]] is obvious when you > > > > look at it from the right angle :/ > > > > > > > > > > > > I have tried your $i suggestion, as in: > > > > > > > > <xforms:range ref="q[2]" start="1" end="5" step="1"> > > > > <xforms:hint> > > > > <xforms:output value="for $i in . return > > > > instance('competence-instance')/competence[$i]"/> > > > > </xforms:hint> > > > > </xforms:range> > > > > > > > > I think that the '.' refers to the current node in scope, which I > > > > think is q[2] from the ref attribute. > > > > > > > > It does result in one of the competence values being displayed, but > > > > it's always the first one, and it doesn't change when the slider is > > > > moved. > > > > To see if it was to do with the initial value of the q[2] node I set > > > > it to 3, and now I'm doubley confused. > > > > As the control is (hopefully) bound to the node with: > > > > > > > > <xforms:bind nodeset="questionnaire"> > > > > ... > > > > <xforms:bind nodeset="Group[2]/q[2]" type="xs:integer" required="true()"/> > > > > ... > > > > > > > > I had assumed that when the page opened the control would be in > > > > position 3 as it should reflect the value in the instance (shouldn't > > > > it?). > > > > > > > > > > > > Any further info would be greatly appreciated. > > > > > > > > Regards, > > > > Paul > > > > > > > > > > > > On 22/06/07, David McIntyre <[hidden email]> wrote: > > > >> > > > >> > > > >> Let's see if I can come up with a clear wording of this. > > > >> > > > >> The problem with your XPath expression > > > >> "instance('competence-instance')/competence[q[2]]" is that the > > > >> predicate "q[2]" gets evaluated in the context of the competence node, > > > >> not the original context where "q[2]" made sense. To paraphrase, it > > > >> says "take the top level element of the 'competence-instance' > > > >> instance, and then take each child node which is called competence and > > > >> which has the property that it has a child node called q with position > > > >> 2 (i.e. it has at least two children called q)". > > > >> > > > >> Well, that's obviously not what you want, so the question is how best > > > >> to get what you do want. Others will no doubt have better ideas, but > > > >> one thing you could try is "for $i in . return > > > >> instance('competence-instance')/competence[$i]". That's a strange use > > > >> of a "for" loop which is a useful trick for setting a variable in an > > > >> XPath expression and then referring to it. > > > >> > > > >> Hope this helps, > > > >> > > > >> Dave Mc > > > >> > > > >> > > > >> > > > >> > > > >> > > > >> > > > >> > > > >> Dave McIntyre MA, DPhil, GradDipSci > > > >> Software Developer > > > >> [hidden email] > > > >> P: +64 9 638 0600 > > > >> F: +64 9 638 0699 > > > >> M: +64 21 212 8087 > > > >> S: dave.mcintyre > > > >> www.orionhealth.com > > > >> > > > >> >>> "Paul Saxelby" <[hidden email]> 22/06/2007 11:21 a.m. >>> > > > >> > > > >> Hi, > > > >> First of all, many thanks to those that have helped me so far.. > > > >> > > > >> My problem today probably has an easy solution, but I can't see it. > > > >> > > > >> I have one instance that is being used to collect the data, and > > > >> another that I just want to use to provide a bit of context sensitive > > > >> feedback with. > > > >> The form is almost extensively range control based. Every range has > > > >> values 1-5. The second instance has 5 'competences'. > > > >> If a range control is moved so that its value is 2, I want to display > > > >> the value of the 2nd 'competence'. > > > >> > > > >> The structure of the first instance is: > > > >> <questionnaires> > > > >> <questionnaire name="elearningskillschecklist"> > > > >> <group> > > > >> <q text="fddsadsadsad"/> > > > >> <q text="fddsadsadsad"/> > > > >> <q text="fddsadsadsad"/> > > > >> </group> > > > >> .... > > > >> .... > > > >> </questionnaire> > > > >> </questionnaires> > > > >> > > > >> The structure of the second instance is: > > > >> <competences> > > > >> <competence> > > > >> ... > > > >> ... > > > >> </competences> > > > >> > > > >> Within the form I have range controls set up like this: > > > >> > > > >> <xforms:range ref="q[2]" start="1" end="5" step="1"> > > > >> <xforms:hint> > > > >> <xforms:output > > > >> value="instance('competence-instance')/competence[q[2]]"/> > > > >> </xforms:hint> > > > >> </xforms:range> > > > >> > > > >> As you can see, what I am trying to do is have the competence in the > > > >> position that has been chosen by the control printed as the hint. > > > >> > > > >> If I use output > > > >> value="instance('competence-instance')/competence[2]" for example, > > > >> I get the value of the 2nd competence. > > > >> If I use output value="q[2]" I get the value of the range > > > >> control (an xs:integer). > > > >> > > > >> So why doesn't .... /competence[q[2]] work? > > > >> This seems the logical way of doing what I need to do. > > > >> Can someone put me straight please? > > > >> > > > >> > > > >> Many thanks, > > > >> Paul Saxelby > > > >> > > > >> > > > >> > > > >> -- > > > >> 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 > > > >> > > > >> > > > > > > > > > > > > > -- > > > Orbeon Forms - Web Forms for the Enterprise Done the Right Way > > > http://www.orbeon.com/ > > > > > > > > > > > > -- > > > 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 |
Administrator
|
Paul,
On 6/26/07, Paul Saxelby <[hidden email]> wrote: > Just wondering if anyone had any further info that they could give me > on these problems at all? First, sorry for the delay. I intended to respond earlier, and then got distracted with something else. > The first is that the text shown from the second instance doesn't > change when the range control is moved. I am running the example now, but what do you mean by "text shown from the second instance"? How should we go about reproducing the issue you are having? What is the result you see, and how is it different from what you expect? > The second is that the range control doesn't reflect the value of the > bound node that it references if the node has a value when the form > loads. The range control might not get updated when its value changes if that change is not directly triggered by the user moving the slider. If this is important to you, you might want to consider using radio buttons or a drop-down instead. Alex -- Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise http://www.orbeon.com/ -- 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 |