unexpected behaviour from xforms:repeat + xforms:group

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

unexpected behaviour from xforms:repeat + xforms:group

Henrik Pettersen
All,

I am attempting to achieve alternating row colors in a table rendered by xforms:repeat.

I have an approach which I expected to work, but which is giving me some unexpected output.

Here is my approach (See attached for standalone example):
**********************************************************************
<xhtml:table border="1">
            <xhtml:tr>
                <xhtml:th>odd / even</xhtml:th>
                <xhtml:th>column count</xhtml:th>
            </xhtml:tr>
            <xforms:repeat nodeset="instance('knowledgebases')/aspic:knowledgebase" id="repeat-knowledgebase">
                <xforms:group ref=".[(count(preceding-sibling::aspic:knowledgebase) + 1) mod 2 = 0]">
                    <xhtml:tr>
                        <xhtml:td>
                            [even]
                        </xhtml:td>
                        <xhtml:td>
                            <xforms:output value="count(preceding-sibling::aspic:knowledgebase) + 1"/>
                        </xhtml:td>
                    </xhtml:tr>
                </xforms:group>
                <xforms:group ref=".[(count(preceding-sibling::aspic:knowledgebase) + 1) mod 2 != 0]">
                    <xhtml:tr>
                        <xhtml:td>
                            [odd]
                        </xhtml:td>
                        <xhtml:td>
                            <xforms:output value="count(preceding-sibling::aspic:knowledgebase) + 1"/>
                        </xhtml:td>
                    </xhtml:tr>
                </xforms:group>
            </xforms:repeat>
        </xhtml:table>



And here is my output:
<form class="xforms-form" action="/editor/xforms-server-submit" method="post" onsubmit="return false"> *********************************************
odd / even column count
[even]
[odd] 1
[even] 2
[odd]
[even]
[odd] 3
[even] 4
[odd]
[even]
[odd] 5
[even] 6
[odd]
[even]
[odd] 7
[even] 8
[odd]
[even]
[odd] 9
[even]
[odd]

Not sure how to achieve my goal, to be honest. Any ideas, anyone?

Thanks!

Sincerely,
Henrik Pettersen
Advanced Computation Laboratory
Cancer Research UK



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

test7.xsl (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: unexpected behaviour from xforms:repeat + xforms:group

Erik Bruchez
Administrator
Henrik,

You can't use xforms:group around xhtml:tr, see this thread:

   http://mail-archive.objectweb.org/ops-users/2006-11/msg00506.html

-Erik

Henrik Pettersen wrote:

> All,
>
> I am attempting to achieve alternating row colors in a table rendered by
> xforms:repeat.
>
> I have an approach which I expected to work, but which is giving me some
> unexpected output.
>
> Here is my approach (See attached for standalone example):
> **********************************************************************
> <xhtml:table border="1">
>             <xhtml:tr>
>                 <xhtml:th>odd / even</xhtml:th>
>                 <xhtml:th>column count</xhtml:th>
>             </xhtml:tr>
>             <xforms:repeat
> nodeset="instance('knowledgebases')/aspic:knowledgebase"
> id="repeat-knowledgebase">
>                 <xforms:group
> ref=".[(count(preceding-sibling::aspic:knowledgebase) + 1) mod 2 = 0]">
>                     <xhtml:tr>
>                         <xhtml:td>
>                             [even]
>                         </xhtml:td>
>                         <xhtml:td>
>                             <xforms:output
> value="count(preceding-sibling::aspic:knowledgebase) + 1"/>
>                         </xhtml:td>
>                     </xhtml:tr>
>                 </xforms:group>
>                 <xforms:group
> ref=".[(count(preceding-sibling::aspic:knowledgebase) + 1) mod 2 != 0]">
>                     <xhtml:tr>
>                         <xhtml:td>
>                             [odd]
>                         </xhtml:td>
>                         <xhtml:td>
>                             <xforms:output
> value="count(preceding-sibling::aspic:knowledgebase) + 1"/>
>                         </xhtml:td>
>                     </xhtml:tr>
>                 </xforms:group>
>             </xforms:repeat>
>         </xhtml:table>
>
>
>
> And here is my output:
> *********************************************
> odd / even column count
> [even]
> [odd] 1
> [even] 2
> [odd]
> [even]
> [odd] 3
> [even] 4
> [odd]
> [even]
> [odd] 5
> [even] 6
> [odd]
> [even]
> [odd] 7
> [even] 8
> [odd]
> [even]
> [odd] 9
> [even]
> [odd]
>
>
> Not sure how to achieve my goal, to be honest. Any ideas, anyone?
>
> Thanks!
>
> Sincerely,
> Henrik Pettersen
> Advanced Computation Laboratory
> Cancer Research UK
>
>
>
> ------------------------------------------------------------------------
>
> <xhtml:html xmlns=""
>            xmlns:xhtml="http://www.w3.org/1999/xhtml"
>            xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>            xmlns:f="http://orbeon.org/oxf/xml/formatting"
>            xmlns:aspic="http://www.cruk.com/aspic/editor/v1"
>            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:xs="http://www.w3.org/2001/XMLSchema"
>            xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
>            xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
>            xmlns:exf="http://www.exforms.org/exf/1-0"
>            xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
>            xsl:version="2.0">
>      <xhtml:head>
>          <xhtml:meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
>          <xhtml:title>Testing Disappearing Label</xhtml:title>
>          <xforms:model>            
>              
>              <xforms:instance id="knowledgebases">            
>                 <aspic:knowledgebases>
>                     <aspic:knowledgebase>
>                         <aspic:id>51</aspic:id>
>                         <aspic:caption>Constant unification</aspic:caption>
>                         <aspic:description>JUNIT_DESCRIPTION</aspic:description>
>                     </aspic:knowledgebase>
>                     <aspic:knowledgebase>
>                         <aspic:id>52</aspic:id>
>                         <aspic:caption>Constant non-unification</aspic:caption>
>                         <aspic:description>JUNIT_DESCRIPTION</aspic:description>
>                     </aspic:knowledgebase>
>                     <aspic:knowledgebase>
>                         <aspic:id>53</aspic:id>
>                         <aspic:caption>BugFix - Should be able to handle floats</aspic:caption>
>                         <aspic:description>JUNIT_DESCRIPTION</aspic:description>
>                     </aspic:knowledgebase>
>                     <aspic:knowledgebase>
>                         <aspic:id>54</aspic:id>
>                         <aspic:caption>Test restricted-rebutting (1) - setup problem</aspic:caption>
>                         <aspic:description>JUNIT_DESCRIPTION</aspic:description>
>                     </aspic:knowledgebase>
>                     <aspic:knowledgebase>
>                         <aspic:id>55</aspic:id>
>                         <aspic:caption>Test restricted-rebutting (2) - with restricted rebutting</aspic:caption>
>                         <aspic:description>JUNIT_DESCRIPTION</aspic:description>
>                     </aspic:knowledgebase>
>                     <aspic:knowledgebase>
>                         <aspic:id>56</aspic:id>
>                         <aspic:caption>Test restricted-rebutting (3) - with transposition</aspic:caption>
>                         <aspic:description>JUNIT_DESCRIPTION</aspic:description>
>                     </aspic:knowledgebase>
>                     <aspic:knowledgebase>
>                         <aspic:id>57</aspic:id>
>                         <aspic:caption>Test last-link. Would be inadmissible if weakest link used.</aspic:caption>
>                         <aspic:description>JUNIT_DESCRIPTION</aspic:description>
>                     </aspic:knowledgebase>
>                     <aspic:knowledgebase>
>                         <aspic:id>58</aspic:id>
>                         <aspic:caption>Basic grounded test</aspic:caption>
>                         <aspic:description>JUNIT_DESCRIPTION</aspic:description>
>                     </aspic:knowledgebase>
>                     <aspic:knowledgebase>
>                         <aspic:id>59</aspic:id>
>                         <aspic:caption>Basic grounded test (admissible)</aspic:caption>
>                         <aspic:description>JUNIT_DESCRIPTION</aspic:description>
>                     </aspic:knowledgebase>
>                 </aspic:knowledgebases>
>              </xforms:instance>
>              
>          </xforms:model>
>      </xhtml:head>
>
>     <xhtml:body>
>         <xhtml:table border="1">
>             <xhtml:tr>
>                 <xhtml:th>odd / even</xhtml:th>
>                 <xhtml:th>column count</xhtml:th>
>             </xhtml:tr>
>             <xforms:repeat nodeset="instance('knowledgebases')/aspic:knowledgebase" id="repeat-knowledgebase">
>                 <xforms:group ref=".[(count(preceding-sibling::aspic:knowledgebase) + 1) mod 2 = 0]">
>                     <xhtml:tr>
>                         <xhtml:td>
>                             [even]
>                         </xhtml:td>
>                         <xhtml:td>
>                             <xforms:output value="count(preceding-sibling::aspic:knowledgebase) + 1"/>
>                         </xhtml:td>
>                     </xhtml:tr>
>                 </xforms:group>
>                 <xforms:group ref=".[(count(preceding-sibling::aspic:knowledgebase) + 1) mod 2 != 0]">
>                     <xhtml:tr>
>                         <xhtml:td>
>                             [odd]
>                         </xhtml:td>
>                         <xhtml:td>
>                             <xforms:output value="count(preceding-sibling::aspic:knowledgebase) + 1"/>
>                         </xhtml:td>
>                     </xhtml:tr>
>                 </xforms:group>
>             </xforms:repeat>
>         </xhtml:table>
> </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

--
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: unexpected behaviour from xforms:repeat + xforms:group

Henrik Pettersen
Thanks, Erik. Then I think I've run out of ideas for how to generate alternating row colors using xforms at the moment. New features should fix this problem, though.

BTW, there is a javascript solution to this problem:
http://www.alistapart.com/articles/zebratables/

Thanks again!

Henrik

On 12/7/06, Erik Bruchez <[hidden email]> wrote:
Henrik,

You can't use xforms:group around xhtml:tr, see this thread:

   http://mail-archive.objectweb.org/ops-users/2006-11/msg00506.html

-Erik

Henrik Pettersen wrote:

> All,
>
> I am attempting to achieve alternating row colors in a table rendered by
> xforms:repeat.
>
> I have an approach which I expected to work, but which is giving me some
> unexpected output.
>
> Here is my approach (See attached for standalone example):
> **********************************************************************
> <xhtml:table border="1">
>             <xhtml:tr>
>                 <xhtml:th>odd / even</xhtml:th>
>                 <xhtml:th>column count</xhtml:th>
>             </xhtml:tr>
>             <xforms:repeat
> nodeset="instance('knowledgebases')/aspic:knowledgebase"
> id="repeat-knowledgebase">
>                 <xforms:group
> ref=".[(count(preceding-sibling::aspic:knowledgebase) + 1) mod 2 = 0]">
>                     <xhtml:tr>
>                         <xhtml:td>
>                             [even]
>                         </xhtml:td>
>                         <xhtml:td>
>                             <xforms:output
> value="count(preceding-sibling::aspic:knowledgebase) + 1"/>
>                         </xhtml:td>
>                     </xhtml:tr>
>                 </xforms:group>
>                 <xforms:group
> ref=".[(count(preceding-sibling::aspic:knowledgebase) + 1) mod 2 != 0]">
>                     <xhtml:tr>
>                         <xhtml:td>
>                             [odd]
>                         </xhtml:td>
>                         <xhtml:td>
>                             <xforms:output
> value="count(preceding-sibling::aspic:knowledgebase) + 1"/>
>                         </xhtml:td>
>                     </xhtml:tr>
>                 </xforms:group>
>             </xforms:repeat>
>         </xhtml:table>
>
>
>
> And here is my output:
> *********************************************
> odd / even    column count
> [even]
> [odd]         1
> [even]        2
> [odd]
> [even]
> [odd]         3
> [even]        4
> [odd]
> [even]
> [odd]         5
> [even]        6
> [odd]

> [even]
> [odd]         7
> [even]        8
> [odd]
> [even]
> [odd]         9
> [even]
> [odd]
>
>
> Not sure how to achieve my goal, to be honest. Any ideas, anyone?
>
> Thanks!
>
> Sincerely,
> Henrik Pettersen
> Advanced Computation Laboratory
> Cancer Research UK
>
>
>
> ------------------------------------------------------------------------
>
> <xhtml:html xmlns=""
>            xmlns:xhtml="http://www.w3.org/1999/xhtml"
>            xmlns:xsl=" http://www.w3.org/1999/XSL/Transform"
>            xmlns:f="http://orbeon.org/oxf/xml/formatting"
>            xmlns:aspic=" http://www.cruk.com/aspic/editor/v1"
>            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:xs=" http://www.w3.org/2001/XMLSchema"
>            xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
>            xmlns:xxf=" http://orbeon.org/oxf/xml/xforms"
>            xmlns:exf="http://www.exforms.org/exf/1-0"
>            xmlns:xxi=" http://orbeon.org/oxf/xml/xinclude"
>            xsl:version="2.0">
>      <xhtml:head>
>          <xhtml:meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
>          <xhtml:title>Testing Disappearing Label</xhtml:title>
>          <xforms:model>
>
>              <xforms:instance id="knowledgebases">
>                 <aspic:knowledgebases>
>                     <aspic:knowledgebase>
>                         <aspic:id>51</aspic:id>
>                         <aspic:caption>Constant unification</aspic:caption>
>                         <aspic:description>JUNIT_DESCRIPTION</aspic:description>

>                     </aspic:knowledgebase>
>                     <aspic:knowledgebase>
>                         <aspic:id>52</aspic:id>
>                         <aspic:caption>Constant non-unification</aspic:caption>
>                         <aspic:description>JUNIT_DESCRIPTION</aspic:description>
>                     </aspic:knowledgebase>
>                     <aspic:knowledgebase>
>                         <aspic:id>53</aspic:id>
>                         <aspic:caption>BugFix - Should be able to handle floats</aspic:caption>
>                         <aspic:description>JUNIT_DESCRIPTION</aspic:description>
>                     </aspic:knowledgebase>
>                     <aspic:knowledgebase>
>                         <aspic:id>54</aspic:id>
>                         <aspic:caption>Test restricted-rebutting (1) - setup problem</aspic:caption>
>                         <aspic:description>JUNIT_DESCRIPTION</aspic:description>
>                     </aspic:knowledgebase>
>                     <aspic:knowledgebase>
>                         <aspic:id>55</aspic:id>
>                         <aspic:caption>Test restricted-rebutting (2) - with restricted rebutting</aspic:caption>
>                         <aspic:description>JUNIT_DESCRIPTION</aspic:description>
>                     </aspic:knowledgebase>
>                     <aspic:knowledgebase>
>                         <aspic:id>56</aspic:id>
>                         <aspic:caption>Test restricted-rebutting (3) - with transposition</aspic:caption>
>                         <aspic:description>JUNIT_DESCRIPTION</aspic:description>
>                     </aspic:knowledgebase>
>                     <aspic:knowledgebase>
>                         <aspic:id>57</aspic:id>
>                         <aspic:caption>Test last-link. Would be inadmissible if weakest link used.</aspic:caption>
>                         <aspic:description>JUNIT_DESCRIPTION</aspic:description>
>                     </aspic:knowledgebase>
>                     <aspic:knowledgebase>
>                         <aspic:id>58</aspic:id>
>                         <aspic:caption>Basic grounded test</aspic:caption>
>                         <aspic:description>JUNIT_DESCRIPTION</aspic:description>
>                     </aspic:knowledgebase>
>                     <aspic:knowledgebase>
>                         <aspic:id>59</aspic:id>
>                         <aspic:caption>Basic grounded test (admissible)</aspic:caption>
>                         <aspic:description>JUNIT_DESCRIPTION</aspic:description>
>                     </aspic:knowledgebase>
>                 </aspic:knowledgebases>
>              </xforms:instance>
>
>          </xforms:model>
>      </xhtml:head>
>
>     <xhtml:body>
>         <xhtml:table border="1">
>             <xhtml:tr>
>                 <xhtml:th>odd / even</xhtml:th>
>                 <xhtml:th>column count</xhtml:th>
>             </xhtml:tr>
>             <xforms:repeat nodeset="instance('knowledgebases')/aspic:knowledgebase" id="repeat-knowledgebase">
>                 <xforms:group ref=".[(count(preceding-sibling::aspic:knowledgebase) + 1) mod 2 = 0]">
>                     <xhtml:tr>
>                         <xhtml:td>
>                             [even]

>                         </xhtml:td>
>                         <xhtml:td>
>                             <xforms:output value="count(preceding-sibling::aspic:knowledgebase) + 1"/>
>                         </xhtml:td>
>                     </xhtml:tr>
>                 </xforms:group>
>                 <xforms:group ref=".[(count(preceding-sibling::aspic:knowledgebase) + 1) mod 2 != 0]">
>                     <xhtml:tr>
>                         <xhtml:td>
>                             [odd]
>                         </xhtml:td>
>                         <xhtml:td>
>                             <xforms:output value="count(preceding-sibling::aspic:knowledgebase) + 1"/>
>                         </xhtml:td>
>                     </xhtml:tr>
>                 </xforms:group>
>             </xforms:repeat>
>         </xhtml:table>
>       </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


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