Select1 Within Repeat

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Select1 Within Repeat

BitByter
Hi XFormers,    ;)

I've problems binding a 'select1' element within a 'repeat' to an element.
My model/instance looks like this:

   <xforms:model id="quiz-model" schema="../../../xsd/quiz.xsd">
      <xforms:instance id="quiz-instance">
         <quiz xmlns="">
            <question>
               <text>What left-handed tennis star won the Grand Slam in 1962 and again in 1969?</text>
               <description>This may be used to give some more details about the question.</description>
               <result>2</result>
               <answers>
                  <answer>
                     <text>John Newcombe</text>
                     <description>John Newcombe Details</description>
                     <value>1</value>
                  </answer>
                  <answer>
                     <text>Arthur Ashe</text>
                     <description>Arthur Ashe Details</description>
                     <value>3</value>
                  </answer>
                  <answer>
                     <text>Rod Laver</text>
                     <description>Rod Laver Details</description>
                     <value>10</value>
                  </answer>
                  <answer>
                     <text>Billie Jean King</text>
                     <description>Billie Jean King Details</description>
                     <value>7</value>
                  </answer>
               </answers>
            </question>

            ...

         </quiz>
      </xforms:instance>
   </xforms:model>


Where "..." should indicate an unbound number of "question" elements
following. I try to ouput this quiz in a table like this:

<table border="1">
   <thead>
      <th>QUESTION</th>
      <th>SCORE</th>
   </thead>
   <xforms:repeat nodeset="instance('quiz-instance')/question">
      <tr>
         <td>
            <xforms:select1 ref="." appearance="full">
               <xforms:label ref="./text" />
               <xforms:help ref="./description" />
               <xforms:itemset nodeset="./answers/answer">
                  <xforms:label ref="./description" />
                  <xforms:value ref="./value" />
               </xforms:itemset>
            </xforms:select1>
         </td>
         <td>
            <xforms:output ref="./result" />
         </td>
      </tr>
   </xforms:repeat>
   <tfoot>
      <td>Total Score</td>
      <%--
           Does not work and returns an org.orbeon.saxon.trans.DynamicError
           with the message "Input to sum() contains a value that is neither
           numeric, nor a duration".

         <td><xforms:output ref="sum(/quiz/question/result)" /></td>
      --%>
      <td>0</td>
   </tfoot>
</table>



This way the questions and answers get displayed, but the score is not
displayed correctly, respectively doesn't change when selecting a different
answer. When I change the binding attribute "ref" from the select1 element
from "." to "result", to bind the answer selection to the "result" element
of each question, neither question nor answers are displayed anymore. Is
this a bug, or is the usage simply wrong?

Furthermore also the sum-up of all question scores/result doesn't work and I
don't know how to get it running.  :(   Any ideas how to correctly sum-up
the score?


Cheers,
bitbyter





--
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
Reply | Threaded
Open this post in threaded view
|

Re: Select1 Within Repeat

BitByter
I simply can't get that stuff running! :(

For easier reproduction I've created a minimal WAR hosting the quiz page.
Thus deploying it at your Tomcat installation you should be able to request
it under the address http://localhost:8080/my-app/xforms-jsp/quiz/quiz.jsp.

What I noticed is, the questions and answers don't get displayed in this WAR
, independet what I enter for the ref attribute of the select1 control. But
in my complete web application these are displayed when having ref set to
"." - although every XForms control displayed is followed by a red
exclamation mark (!).

Would be really great if someone could give me a hint on how to get this
quiz running, cause I've no more ideas.

- bitbyter




Monday, May 7, 2007, 5:41:51 PM, I wrote:

> Hi XFormers,    ;)

> I've problems binding a 'select1' element within a 'repeat' to an element.
> My model/instance looks like this:

>    <xforms:model id="quiz-model" schema="../../../xsd/quiz.xsd">
>       <xforms:instance id="quiz-instance">
>          <quiz xmlns="">
>             <question>
>                <text>What left-handed tennis star won the Grand Slam in 1962 and again in 1969?</text>
>                <description>This may be used to give some more details about the question.</description>
>                <result>2</result>
>                <answers>
>                   <answer>
>                      <text>John Newcombe</text>
>                      <description>John Newcombe Details</description>
>                      <value>1</value>
>                   </answer>
>                   <answer>
>                      <text>Arthur Ashe</text>
>                      <description>Arthur Ashe Details</description>
>                      <value>3</value>
>                   </answer>
>                   <answer>
>                      <text>Rod Laver</text>
>                      <description>Rod Laver Details</description>
>                      <value>10</value>
>                   </answer>
>                   <answer>
>                      <text>Billie Jean King</text>
>                      <description>Billie Jean King Details</description>
>                      <value>7</value>
>                   </answer>
>                </answers>
>             </question>

>             ...

>          </quiz>
>       </xforms:instance>
>    </xforms:model>


> Where "..." should indicate an unbound number of "question" elements
> following. I try to ouput this quiz in a table like this:

> <table border="1">
>    <thead>
>       <th>QUESTION</th>
>       <th>SCORE</th>
>    </thead>
>    <xforms:repeat nodeset="instance('quiz-instance')/question">
>       <tr>
>          <td>
>             <xforms:select1 ref="." appearance="full">
>                <xforms:label ref="./text" />
>                <xforms:help ref="./description" />
>                <xforms:itemset nodeset="./answers/answer">
>                   <xforms:label ref="./description" />
>                   <xforms:value ref="./value" />
>                </xforms:itemset>
>             </xforms:select1>
>          </td>
>          <td>
>             <xforms:output ref="./result" />
>          </td>
>       </tr>
>    </xforms:repeat>
>    <tfoot>
>       <td>Total Score</td>
>       <%--
>            Does not work and returns an org.orbeon.saxon.trans.DynamicError
>            with the message "Input to sum() contains a value that is neither
>            numeric, nor a duration".

>          <td><xforms:output ref="sum(/quiz/question/result)" /></td>
>       --%>
>       <td>0</td>
>    </tfoot>
> </table>



> This way the questions and answers get displayed, but the score is not
> displayed correctly, respectively doesn't change when selecting a different
> answer. When I change the binding attribute "ref" from the select1 element
> from "." to "result", to bind the answer selection to the "result" element
> of each question, neither question nor answers are displayed anymore. Is
> this a bug, or is the usage simply wrong?

> Furthermore also the sum-up of all question scores/result doesn't work and I
> don't know how to get it running.  :(   Any ideas how to correctly sum-up
> the score?


> Cheers,
> bitbyter


--
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

my-app.war (10K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Select1 Within Repeat

Erik Bruchez
Administrator
BitByter,

Try something like this:

<xforms:output value="sum(for $value in /quiz/question/result return
number($value))"/>

-Erik

BitByter wrote:

> I simply can't get that stuff running! :(
>
> For easier reproduction I've created a minimal WAR hosting the quiz page.
> Thus deploying it at your Tomcat installation you should be able to request
> it under the address http://localhost:8080/my-app/xforms-jsp/quiz/quiz.jsp.
>
> What I noticed is, the questions and answers don't get displayed in this WAR
> , independet what I enter for the ref attribute of the select1 control. But
> in my complete web application these are displayed when having ref set to
> "." - although every XForms control displayed is followed by a red
> exclamation mark (!).
>
> Would be really great if someone could give me a hint on how to get this
> quiz running, cause I've no more ideas.
>
> - bitbyter
>
>
>
>
> Monday, May 7, 2007, 5:41:51 PM, I wrote:
>
>> Hi XFormers,    ;)
>
>> I've problems binding a 'select1' element within a 'repeat' to an element.
>> My model/instance looks like this:
>
>>    <xforms:model id="quiz-model" schema="../../../xsd/quiz.xsd">
>>       <xforms:instance id="quiz-instance">
>>          <quiz xmlns="">
>>             <question>
>>                <text>What left-handed tennis star won the Grand Slam in 1962 and again in 1969?</text>
>>                <description>This may be used to give some more details about the question.</description>
>>                <result>2</result>
>>                <answers>
>>                   <answer>
>>                      <text>John Newcombe</text>
>>                      <description>John Newcombe Details</description>
>>                      <value>1</value>
>>                   </answer>
>>                   <answer>
>>                      <text>Arthur Ashe</text>
>>                      <description>Arthur Ashe Details</description>
>>                      <value>3</value>
>>                   </answer>
>>                   <answer>
>>                      <text>Rod Laver</text>
>>                      <description>Rod Laver Details</description>
>>                      <value>10</value>
>>                   </answer>
>>                   <answer>
>>                      <text>Billie Jean King</text>
>>                      <description>Billie Jean King Details</description>
>>                      <value>7</value>
>>                   </answer>
>>                </answers>
>>             </question>
>
>>             ...
>
>>          </quiz>
>>       </xforms:instance>
>>    </xforms:model>
>
>
>> Where "..." should indicate an unbound number of "question" elements
>> following. I try to ouput this quiz in a table like this:
>
>> <table border="1">
>>    <thead>
>>       <th>QUESTION</th>
>>       <th>SCORE</th>
>>    </thead>
>>    <xforms:repeat nodeset="instance('quiz-instance')/question">
>>       <tr>
>>          <td>
>>             <xforms:select1 ref="." appearance="full">
>>                <xforms:label ref="./text" />
>>                <xforms:help ref="./description" />
>>                <xforms:itemset nodeset="./answers/answer">
>>                   <xforms:label ref="./description" />
>>                   <xforms:value ref="./value" />
>>                </xforms:itemset>
>>             </xforms:select1>
>>          </td>
>>          <td>
>>             <xforms:output ref="./result" />
>>          </td>
>>       </tr>
>>    </xforms:repeat>
>>    <tfoot>
>>       <td>Total Score</td>
>>       <%--
>>            Does not work and returns an org.orbeon.saxon.trans.DynamicError
>>            with the message "Input to sum() contains a value that is neither
>>            numeric, nor a duration".
>
>>          <td><xforms:output ref="sum(/quiz/question/result)" /></td>
>>       --%>
>>       <td>0</td>
>>    </tfoot>
>> </table>
>
>
>
>> This way the questions and answers get displayed, but the score is not
>> displayed correctly, respectively doesn't change when selecting a different
>> answer. When I change the binding attribute "ref" from the select1 element
>> from "." to "result", to bind the answer selection to the "result" element
>> of each question, neither question nor answers are displayed anymore. Is
>> this a bug, or is the usage simply wrong?
>
>> Furthermore also the sum-up of all question scores/result doesn't work and I
>> don't know how to get it running.  :(   Any ideas how to correctly sum-up
>> the score?
>
>
>> Cheers,
>> bitbyter

--
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
Reply | Threaded
Open this post in threaded view
|

Re[2]: Select1 Within Repeat

BitByter
Hi Erik,

I'll try out the sum calculation as soon as I get the questions/answers
displayed. Could you help me with that, cause I really don't know what I'm
doing wrong. I think I'm using the XForms controls the way they are
documented. So currently it is really frustrating. :((  And the pity is that
I even don't know how to debug this kind of bugs/problems.

- (frustrated) bitbyter


Tuesday, May 8, 2007, 8:58:11 PM, you wrote:

> BitByter,

> Try something like this:

> <xforms:output value="sum(for $value in /quiz/question/result return
number($value))"/>>

> -Erik

> BitByter wrote:
>> I simply can't get that stuff running! :(
>>
>> For easier reproduction I've created a minimal WAR hosting the quiz page.
>> Thus deploying it at your Tomcat installation you should be able to request
>> it under the address http://localhost:8080/my-app/xforms-jsp/quiz/quiz.jsp.
>>
>> What I noticed is, the questions and answers don't get displayed in this WAR
>> , independet what I enter for the ref attribute of the select1 control. But
>> in my complete web application these are displayed when having ref set to
>> "." - although every XForms control displayed is followed by a red
>> exclamation mark (!).
>>
>> Would be really great if someone could give me a hint on how to get this
>> quiz running, cause I've no more ideas.
>>
>> - bitbyter
>>
>>
>>
>>
>> Monday, May 7, 2007, 5:41:51 PM, I wrote:
>>
>>> Hi XFormers,    ;)
>>
>>> I've problems binding a 'select1' element within a 'repeat' to an element.
>>> My model/instance looks like this:
>>
>>>    <xforms:model id="quiz-model" schema="../../../xsd/quiz.xsd">
>>>       <xforms:instance id="quiz-instance">
>>>          <quiz xmlns="">
>>>             <question>
>>>                <text>What left-handed tennis star won the Grand Slam in 1962 and again in 1969?</text>
>>>                <description>This may be used to give some more details about the question.</description>
>>>                <result>2</result>
>>>                <answers>
>>>                   <answer>
>>>                      <text>John Newcombe</text>
>>>                      <description>John Newcombe Details</description>
>>>                      <value>1</value>
>>>                   </answer>
>>>                   <answer>
>>>                      <text>Arthur Ashe</text>
>>>                      <description>Arthur Ashe Details</description>
>>>                      <value>3</value>
>>>                   </answer>
>>>                   <answer>
>>>                      <text>Rod Laver</text>
>>>                      <description>Rod Laver Details</description>
>>>                      <value>10</value>
>>>                   </answer>
>>>                   <answer>
>>>                      <text>Billie Jean King</text>
>>>                      <description>Billie Jean King Details</description>
>>>                      <value>7</value>
>>>                   </answer>
>>>                </answers>
>>>             </question>
>>
>>>             ...
>>
>>>          </quiz>
>>>       </xforms:instance>
>>>    </xforms:model>
>>
>>
>>> Where "..." should indicate an unbound number of "question" elements
>>> following. I try to ouput this quiz in a table like this:
>>
>>> <table border="1">
>>>    <thead>
>>>       <th>QUESTION</th>
>>>       <th>SCORE</th>
>>>    </thead>
>>>    <xforms:repeat nodeset="instance('quiz-instance')/question">
>>>       <tr>
>>>          <td>
>>>             <xforms:select1 ref="." appearance="full">
>>>                <xforms:label ref="./text" />
>>>                <xforms:help ref="./description" />
>>>                <xforms:itemset nodeset="./answers/answer">
>>>                   <xforms:label ref="./description" />
>>>                   <xforms:value ref="./value" />
>>>                </xforms:itemset>
>>>             </xforms:select1>
>>>          </td>
>>>          <td>
>>>             <xforms:output ref="./result" />
>>>          </td>
>>>       </tr>
>>>    </xforms:repeat>
>>>    <tfoot>
>>>       <td>Total Score</td>
>>>       <%--
>>>            Does not work and returns an org.orbeon.saxon.trans.DynamicError
>>>            with the message "Input to sum() contains a value that is neither
>>>            numeric, nor a duration".
>>
>>>          <td><xforms:output ref="sum(/quiz/question/result)" /></td>
>>>       --%>
>>>       <td>0</td>
>>>    </tfoot>
>>> </table>
>>
>>
>>
>>> This way the questions and answers get displayed, but the score is not
>>> displayed correctly, respectively doesn't change when selecting a different
>>> answer. When I change the binding attribute "ref" from the select1 element
>>> from "." to "result", to bind the answer selection to the "result" element
>>> of each question, neither question nor answers are displayed anymore. Is
>>> this a bug, or is the usage simply wrong?
>>
>>> Furthermore also the sum-up of all question scores/result doesn't work and I
>>> don't know how to get it running.  :(   Any ideas how to correctly sum-up
>>> the score?
>>
>>
>>> Cheers,
>>> bitbyter







--
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
Reply | Threaded
Open this post in threaded view
|

Re[3]: Select1 Within Repeat

BitByter
For those that are interested: I got the quiz more or less running.

The problem displaying the questions/answers was due to some namespace
problems. Before I declared following namespaces:

<html
      xmlns:xhtml="http://www.w3.org/1999/xhtml"
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xforms="http://www.w3.org/2002/xforms"
      xmlns:ev="http://www.w3.org/2001/xml-events">

Notice that the default namespace and the namespace for "xhtml" got the same
value. After removing the declaration for default namespace and adapting the
XHTML page, the questions and answers are displayed correctly. Seems Orbeon
Forms has problems when using the default namespace for XHTML. I don't know
why, but maybe someone else could explain that?! :)

Furthermore I had to use the Orbeon Forms' XPath extension
"xxforms:repeat-current()" to successfully get the questions and answers
displayed. So the working XForms stuff looks like this:

<xhtml:table border="1">
   <xhtml:thead>
      <xhtml:th>QUESTION</xhtml:th>
      <xhtml:th>SCORE</xhtml:th>
   </xhtml:thead>
     <xforms:repeat nodeset="instance('quiz-instance')/question">
         <xhtml:tr>
            <xhtml:td>
               <xforms:select1 ref="./result" appearance="full">
                  <xforms:label ref="xxforms:repeat-current()/text" />
                  <xforms:help ref="xxforms:repeat-current()/description" />
                  <xforms:itemset nodeset="xxforms:repeat-current()/answers/answer">
                     <xforms:label ref="./description" />
                     <xforms:value ref="./value" />
                  </xforms:itemset>
               </xforms:select1>
            </xhtml:td>
            <xhtml:td>
               <xforms:output ref="result" />
            </xhtml:td>
         </xhtml:tr>
      </xforms:repeat>
   <xhtml:tfoot>
      <xhtml:td>Total Score</xhtml:td>
      <xhtml:td>
         <xforms:output value="sum(for $value in /quiz/question/result return number($value))"/>
      </xhtml:td>
   </xhtml:tfoot>
</xhtml:table>


I'm just wondering why I can't simply use "./text" instead of
"xxforms:repeat-current()/text"? Could I achieve the same result without using
"xxforms:repeat-current()"? Anybody got an idea?

Furthermore when I run that XForms app directly within Orbeon Forms as XHTML
everything is displayed fine. But when I run the same stuff as JSP in my
seperate web application, a red exclamation mark is displayed after each
XForms control (see attached screenshot). Anybody got an idea why and how I
could turn that off?


Cheers,
bitbyter


--
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

quiz-screenshot.jpg (59K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re[2]: Select1 Within Repeat

BitByter
In reply to this post by Erik Bruchez
Hello Erik,

Tuesday, May 8, 2007, 8:58:11 PM, you wrote:

> Try something like this:
>
> <xforms:output value="sum(for $value in /quiz/question/result return number($value))"/>

That works fine. But could you tell me how to ommit empty <result/> elements
in the sum calculation?

- bitbyter





--
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
Reply | Threaded
Open this post in threaded view
|

Re: Select1 Within Repeat

Joseph Lawrence
Hello Bitbyter,
try:

<xforms:output value="sum(for $value in /quiz/question/result[.!=''] return
number($value))"/>

Or

<xforms:output value="sum(for $value in /quiz/question/result[.castable as xs:integer] return
number($value))"/>

Thanks
Joseph Lawrence
Stabilix Solutions


BitByter <[hidden email]> wrote:
Hello Erik,

Tuesday, May 8, 2007, 8:58:11 PM, you wrote:

> Try something like this:
>
>

That works fine. But could you tell me how to ommit empty elements
in the sum calculation?

- bitbyter




--
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


Ahhh...imagining that irresistible "new car" smell?
Check out new cars at Yahoo! Autos.

--
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
Reply | Threaded
Open this post in threaded view
|

Re[2]: Select1 Within Repeat

BitByter
Hello Joseph,

Thursday, May 10, 2007, 5:56:51 PM, you wrote:

>  try:
>
>  <xforms:output  value="sum(for  $value  in  /quiz/question/result[.!='']
> return number($value))"/>>

That works perfect!  :)  Thanks a lot!

- bitbyter





--
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