Repeat inside repeat and inverse descending order

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

Repeat inside repeat and inverse descending order

J. Thorsten Stumpf
Hi there!

And again a question - well, actually again two questions in one message
- but all questions depend on the same information.

Maybe anybody has got an idea what to do.


We've got the following XML data structure:

<root>
   <options type="a">
     <option id="o_a_1" name="Foo">
       <options type="b">
         <option id="o_a_1_b_1" name="Full Service">
           <date start="09/28/2008" end="09/31/2008" id="o_a_1_b_1_t_1"/>
           <date start="10/01/2008" end="10/12/2008" id="o_a_1_b_1_t_2"/>
           <date start="10/02/2008" end="09/13/2008" id="o_a_1_b_1_t_3"/>
         </option>
         <option id="o_a_1_b_2" name="Package 1">
           <date start="09/28/2008" end="09/31/2008" id="o_a_1_b_2_t_1"/>
           <date start="10/01/2008" end="10/12/2008" id="o_a_1_b_2_t_2"/>
         </option>
         <option id="o_a_1_b_3" name="Package 2">
           <date start="10/01/2008" end="10/12/2008" id="o_a_1_b_3_t_1"/>
           <date start="10/02/2008" end="09/13/2008" id="o_a_1_b_3_t_2"/>
         </option>
       </options>
     </option>
     <option id="o_a_2">
       <options type="b" name="Bar">
         <option id="o_a_2_b_1" name="Full Service">
         ...
         </option>
         ...
       </options>
     </option>
     ...
   </options>
</root>

The data structure represents several options of type 'b' the user can
choose from ('Full Service', 'Package 1' or 'Package 2'). These services
are available dependant on dates, but the time ranges can overlap and
one or more services can be available with the same start and end date
(but the dates' ids differ). Actually there are several additional
informations below date (childs of the date node) but I skipped them for
better understanding.

So far that's "easy".
But we have to present the user a XForms based form, that inverts the
order of option of type 'b' and date or presents all dates for each
'b'-option at once.

The original request was to select a date and based on the date are the
matching option's of type b available.
We told the customer, that it can't be done within a week based on the
given data structure, which is true because the given structure above is
just a tiny bit of the original structure and we're new to XForms.
(We can't/didn't wan't to establish a transformation process of the
delivered document.)

(I know, that the structure is awkward for this purpose and doesn't fit,
but I can't alter it.)


Question 1:
===========
After long discussions we managed to commit on an alternate way.

The user will get an output consisting of three tables, each with the
matching dates for the option type.
He can select one of the dates by clicking on the row.

We thought that it is easy to implement by setting up two repeats in the
same XForm form, the first iterating over the service options, the
second, inner one, iterating over the dates.

(I attach the XForms declarations at the end of this message.)

But the behaviour of Orbeon is a bit strange: It highlights the line
before the actual clicked.

How can I fix that?
It seems, that the outer repeats index is used for the highlighting.

In fact we don't need the outer repeat to have a highlighting at all.


Question 2:
===========
Confronted with this problem I searched for other solutions and started
to think over the original request again.

It could more or less easily be done by XQuery.
I found an Orbeon XQuery Sandbox and played aroiund with it. In the end,
I'm not shure: Can Orbeon handle XQuery requests within a page without
server submits, or does it have to submit every XQuery request to the
server?

Can XQuerys be done 'inpage'?

My plan would be to use the XQuery distinct-values function to get just
a list of the distinct dates and present this list to the user.

Next I'd use XQuery to select all 'b' options that have a child with the
matching start and end date.


Question 3:
===========
As a additional backup I could imagine to do a XSL tranformation with
sort adding an additional 'option' level to the document representing
the distinct dates. But that would increase the documents size by a
factor of three to 25 or even bigger - much bigger!

Additionaly: The XML document is loaded dynamically in the XForm, so
what could be the best practice to establish an XSL transformation?

Create a seperate Orbeon XForms application/additional page flow that is
only doing the transformation?

Or can it be done 'inpage'?
As far as I have read it can't because XSL is done before the page is
loaded. Am I right?



--------------

XForms form definition:

<xforms:repeat
nodeset="//options[@type='a']/option/options[@typ='b']/option"
id="option_rep">

     <xhtml:h1><xforms:output ref="@name"/></xhtml:h1>

     <xhtml:table>
         <xhtml:tr>
             <xhtml:th>Name</xhtml:th>
             <xhtml:th>Start</xhtml:th>
             <xhtml:th>End</xhtml:th>
             <xhtml:th>...</xhtml:th>
         </xhtml:tr>

         <xforms:repeat nodeset="date" id="date_rep">
             <xhtml:tr>
                 <xhtml:td>
                     <xforms:output value="@id"/>
                 </xhtml:td>
                 <xhtml:td>
                     <xforms:output value="@start"/>
                 </xhtml:td>
                 <xhtml:td>
                     <xforms:output value="@end"/>
                 </xhtml:td>
                 <xhtml:td>
                     ...
                 </xhtml:td>
             </xhtml:tr>
         </xforms:repeat>
     </xhtml:table>
</xforms:repeat>


Thanks in advance,

Thorsten


--
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
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Repeat inside repeat and inverse descending order

Erik Bruchez
Administrator
> But the behaviour of Orbeon is a bit strange: It highlights the line  
> before the actual clicked.
>
> How can I fix that?
> It seems, that the outer repeats index is used for the highlighting.
>
> In fact we don't need the outer repeat to have a highlighting at all.

Here, Firebug is your friend:

   http://getfirebug.com/

You will see with Firebug why the row is highlighted: the XForms  
engine places classes called xforms-repeat-selected-item-1, xforms-
repeat-selected-item-2, xforms-repeat-selected-item-3, and xforms-
repeat-selected-item-4 around repeat iterations so that you can style  
things.

You can overwrite this with your own CSS, e.g.:

   .xforms-form .xforms-repeat-selected-item-1 { background-color:  
transparent }

> I found an Orbeon XQuery Sandbox and played aroiund with it. In the  
> end, I'm not shure: Can Orbeon handle XQuery requests within a page  
> without server submits, or does it have to submit every XQuery  
> request to the server?

I guess the answer is "no", and the reason is twofold:

* The XForms engine resides partly on the client, partly on the  
server. If by "client" you mean the browser, then no, XQuery won't run  
there.

* There is no XQuery integration directly within the XForms engine.  
You have to use xforms:submission to call a service running XQuery  
(for example implemented in XPL), or to use the xxforms:call-xpl()  
function to call XQuery within, for example, xforms:insert.

> Additionaly: The XML document is loaded dynamically in the XForm, so  
> what could be the best practice to establish an XSL transformation?
>
> Create a seperate Orbeon XForms application/additional page flow  
> that is only doing the transformation?

Create a REST service that takes XML as input, performs the XSLT  
transformation, and produces XML as output. You can implement such a  
service in XPL, and expose it through the page flow.

Or, create a REST service that both loads the data and performs the  
XSLT transformation.

-Erik

--
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
OW2 mailing lists service home page: http://www.ow2.org/wws