XForms Engine Static XPath Dependency Analysis Query

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

XForms Engine Static XPath Dependency Analysis Query

Graham May-2
We are currently using Orbeon Forms version 4.1.0.201304182144-PE. We are currently developing a complex data driven absence reporting form in Orbeon Forms using the Form Builder. We are seeking to take advantage of the XForms recalculation algorithm for static XPath Dependency Analysis. We largely need to take advantage of this due to the sheer amount of permutations possible in the absence reporting form. Sections or individuals fields become visible/hidden/mandatory/optional based on choices made by the user. Subsequently we have built a form with multiple hidden sections; load configuration section, intermediate section. The load configuration section contains values that are known on form load that do not subsequently change. The intermediate section contains calculated values which change based on user selection. What we have witnessed is that the XPath Dependency Analysis doesn't not always determine nodes which are dependent on other nodes. So we have situations where sections of the form are not in the correct state. If we fully expand each XPath the correct value is determined however this leaves us with a maintenance issue.

We have been using the following URI's for guidance on what level of support Orbeon provides with respect to the XForms Recalculation Algorithm:
http://wiki.orbeon.com/forms/projects/xforms-engine-dependency-system
http://wiki.orbeon.com/forms/projects/xforms-engine-dependency-system/project-xforms-ui-dependencies

Example:
label1: has hours lost question, always equal to 1
label2: end period for absence known, calculated based on whether the end period of absence period has been populated
label3: hours worked evenly, defaulted to true, changes if the user is prompted as to whether they are paid weekly (Yes/No radio button)
label4: should as for hours lost flag, calculated based on all of the above values being true (label1 and label2 and label2)
label5: show working hours page, calculated, currently set to the result of the above expression (label4)

What we witness is label4 being always been false even when label1, label2 and label3 are all true. If we fully expand all of the XPath expressions in labels 1-3 into a separate XPath the result is true.

We've attached a copy of the XForm that we have developed using the Orbeon Form builder.

We initially thought this was down to us using match any (//) XPath expressions but we also witnessed the same problem when entering the full XPath from the root node.

Many thanks
Graham

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].

absence-xform.xml (37K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: XForms Engine Static XPath Dependency Analysis Query

Erik Bruchez
Administrator
Graham,

I am running your form, but you mention things like "label1", "label2", etc., which don't appear in your form. This makes it hard to follow the logic you describe. I can suppose that "label4", "should as for hours lost flag", is in fact "should-ask-for-hours-lost-flag-expanded". But what about the other ones?

Can you provide exact steps, based on the names in the form you sent, showing doesn't work? What should I fill in in the form? What should I see?

-Erik
Reply | Threaded
Open this post in threaded view
|

Re: XForms Engine Static XPath Dependency Analysis Query

Graham May-2
Hi Erik

Thanks for the response. I have provided a set of steps to repeat the problem

You can enter any values that you want into the mandatory fields in "Employee / Absence Details" section, these values don't really do anything apart from the optional 'Date became fit for work'.
The "System Fields" sections in reality should be hidden but we've just left them visible in order to enable some level of debugging.

Steps to re-create problem
- Enter values for all of the following fields in the "Employee / Absence Details" section: Title, Initials, Surname, Assignment Number, Reason for Absence, First date unit for work, Did the employee work for part of this day, Date became fit for work, type of illness
- We believe at this point that the "Working Hours" section should be visible.
The visibility of the "Working Hours" section should be visible if /system-fields-intermediate-logic/show-working-hours-page is true
/system-fields-intermediate-logic/show-working-hours-page, believe this value should be true but it is false, true if system-fields-intermediate-logic/should-ask-for-hours-lost-flag is true
/system-fields-intermediate-logic/should-ask-for-hours-lost-flag, believe this value should be true but it is false, this value is based on the ANDing of 3 XPath Expressions
The reason that we believe that /system-fields-intermediate-logic/should-ask-for-hours-lost-flag should be true is that if we fully expand all of the XPath Expressions into 1 XPath expression as is the case for /system-fields-intermediate-logic/should-ask-for-hours-lost-flag-expanded, we see that /system-fields-intermediate-logic/should-ask-for-hours-lost-flag-expanded is actually true.

We made a mistake in one of the XPath Expressions cited above. I have attached a new copy of the form which corrects the XPath expressions however the same problem still occurs.

In regard to the XForms Recalculation Algorithm we would expect that the engine would order the expressions so that dependent expressions are evaluated first? We were worried that we might have created a cyclic dependency that couldn't be evaluated but this doesn't appear to be the case. We believe that we have highlighted an issue although our assertions in regard to the expected behaviour may be incorrect?

Many thanks
Graham

On Thursday, 15 January 2015 20:01:21 UTC, ebruchez wrote:
Graham,

I am running your form, but you mention things like "label1", "label2",
etc., which don't appear in your form. This makes it hard to follow the
logic you describe. I can suppose that "label4", "should as for hours lost
flag", is in fact "should-ask-for-hours-lost-flag-expanded". But what about
the other ones?

Can you provide exact steps, based on the names in the form you sent,
showing doesn't work? What should I fill in in the form? What should I see?

-Erik

--
View this message in context: <a href="http://discuss.orbeon.com/XForms-Engine-Static-XPath-Dependency-Analysis-Query-tp4659430p4659438.html" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fdiscuss.orbeon.com%2FXForms-Engine-Static-XPath-Dependency-Analysis-Query-tp4659430p4659438.html\46sa\75D\46sntz\0751\46usg\75AFQjCNEocrjnSTJMDOvy36sF9mu1JPeGDw';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fdiscuss.orbeon.com%2FXForms-Engine-Static-XPath-Dependency-Analysis-Query-tp4659430p4659438.html\46sa\75D\46sntz\0751\46usg\75AFQjCNEocrjnSTJMDOvy36sF9mu1JPeGDw';return true;">http://discuss.orbeon.com/XForms-Engine-Static-XPath-Dependency-Analysis-Query-tp4659430p4659438.html
Sent from the Orbeon Forms community mailing list mailing list archive at Nabble.com.

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].

absence-xform.xml (37K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: XForms Engine Static XPath Dependency Analysis Query

Erik Bruchez
Administrator
Graham,

I haven't had time to look at this yet, but will try.

One thing I can say is that the dependency engine does not determine an evaluation order. So that aspect will not work.

Slightly relevant, we have an RFE about improving the way we handle dependencies:

    https://github.com/orbeon/orbeon-forms/issues/1192

-Erik
Reply | Threaded
Open this post in threaded view
|

Re: XForms Engine Static XPath Dependency Analysis Query

Erik Bruchez
Administrator
Graham,

The first thing I find incorrect is that you use, for that flag:

    system-intermediate-logic-section

when the section element is in fact:

    system-fields-intermediate-logic

If I change that, it seems that things work.

A few other comments:

1. You don't need text() in XPath expressions (only VERY rarely)
2. You could also use variables to refer to fields, so instead of:

    instance()/system-fields-intermediate-logic/absence-end-known-logic-only-field

use:

    $absence-end-known-logic-only-field

This might help prevent some typos.

-Erik
Reply | Threaded
Open this post in threaded view
|

Re: XForms Engine Static XPath Dependency Analysis Query

Graham May-2
Hi Erik

Thanks for the advice. We have made the alterations cited and we are now using variable references instead of full XPath Expressions. It's much more convenient using the variable references instead of the full XPath Expressions.

We've attached an updated form that uses variable references.

Although the 'Working Hours' section is now visible we think that there is a further problem.

If we fill in the form as follows:
  • Employee / Absence Details
    • Title: Mr
    • Initials: a
    • Surname: a
    • Assignment Number: a
    • Reason for absence: Sickness
    • First data unfit for work: 08/02/2012 (we've modified our Orbeon properties to use dd/mm/yyyy)
    • Did the employee work for part of this day: Yes
    • Date became fit for work: 09/02/2012
    • Type of illness: Cold / Cough / Flu
  • Working Hours
    • Is the employee paid weekly: Yes
    • Total working hours lost for period of absence on return to work: 7
  • Your Details
    • This form has been completed by: a
    • Office phone number: a

When we change 'Is the employee paid weekly' to No the following variables change:
- hourWorkedEvenlyFLAG: false
- should-ask-for-hours-lost-flag-expanded: false
We would anticipate that:
- shouldAskForHoursLostFLAG should be false, however its true. We would expect it to be false as hoursWorkedEvenlyFLAG is false and it's anded in the expression that calculates the value of shouldAskForHoursLostFLAG. So that's why we believe it should false.

Our assertion that it should be false is based on our cursory reading of: http://www.w3.org/TR/xforms/#recalc
Appendix C Recalculation Sequence Algorithm
3. A topological sort is performed on the vertices of the pertinent dependency subgraph, resulting in an order of evaluation in which each vertex is evaluated only after those vertices on which it depends and before all vertices which depend on it. The topological sort algorithm is discussed at [Algorithms].

Many thanks

On Friday, 23 January 2015 02:13:20 UTC, ebruchez wrote:
Graham,

The first thing I find incorrect is that you use, for that flag:

    system-intermediate-logic-section

when the section element is in fact:

    system-fields-intermediate-logic

If I change that, it seems that things work.

A few other comments:

1. You don't need text() in XPath expressions (only VERY rarely)
2. You could also use variables to refer to fields, so instead of:

   
instance()/system-fields-intermediate-logic/absence-end-known-logic-only-field

use:

    $absence-end-known-logic-only-field

This might help prevent some typos.

-Erik

--
View this message in context: <a href="http://discuss.orbeon.com/XForms-Engine-Static-XPath-Dependency-Analysis-Query-tp4659430p4659473.html" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fdiscuss.orbeon.com%2FXForms-Engine-Static-XPath-Dependency-Analysis-Query-tp4659430p4659473.html\46sa\75D\46sntz\0751\46usg\75AFQjCNGhuL6z77GrtNmzFhJo3Hjn9TGYMQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fdiscuss.orbeon.com%2FXForms-Engine-Static-XPath-Dependency-Analysis-Query-tp4659430p4659473.html\46sa\75D\46sntz\0751\46usg\75AFQjCNGhuL6z77GrtNmzFhJo3Hjn9TGYMQ';return true;">http://discuss.orbeon.com/XForms-Engine-Static-XPath-Dependency-Analysis-Query-tp4659430p4659473.html
Sent from the Orbeon Forms community mailing list mailing list archive at Nabble.com.

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].

absence-form-using-references.xml (36K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: XForms Engine Static XPath Dependency Analysis Query

Alessandro  Vernet
Administrator
Hi Graham,

So you're saying that you would expect shouldAskForHoursLostFLAG to be false, but it is true, which I was able to reproduce.

shouldAskForHoursLostFLAG := $absence-end-known-logic-only-field eq true() and $has-hours-lost-question eq true() and $hours-worked-evenly-flag eq true()

But in my case hours-worked-evenly-flag is true. It's computed as:

hours-worked-evenly-flag := if (string-length(normalize-space($employee-paid-weekly)) eq 0) then true() else $employee-paid-weekly eq 'yes'

Since we put Is the employee paid weekly: Yes, I would expect hours-worked-evenly-flag to be true, and hence shouldAskForHoursLostFLAG to be true as well. Am I missing something?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: XForms Engine Static XPath Dependency Analysis Query

Alessandro  Vernet
Administrator
And I just updates the labels of the fields to match their name, which makes it easier for me to search things in form:

absence-form-using-references.xml

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: XForms Engine Static XPath Dependency Analysis Query

Graham May-2
In reply to this post by Alessandro Vernet

Hi Alex

Thanks for the update.

The problem as far as I see it is if you change $employee-paid-weekly, setting it to false. $hours-worked-evenly-flag is correctly false but $shouldAskForHoursLostFLAG is incorrectly true. $shouldAskForHoursLostFLAG should not evaluate to true as $hours-worked-evenly-flag is false and it is anded in the XPath expression that calculates $shouldAskForHoursLostFLAG.

Many thanks

On 9 Feb 2015 19:45, "Alessandro Vernet" <[hidden email]> wrote:
Hi Graham,

So you're saying that you would expect shouldAskForHoursLostFLAG to be
false, but it is true, which I was able to reproduce.

shouldAskForHoursLostFLAG := $absence-end-known-logic-only-field eq true()
and $has-hours-lost-question eq true() and $hours-worked-evenly-flag eq
true()

But in my case hours-worked-evenly-flag is true. It's computed as:

hours-worked-evenly-flag := if
(string-length(normalize-space($employee-paid-weekly)) eq 0) then true()
else $employee-paid-weekly eq 'yes'

Since we put Is the employee paid weekly: Yes, I would expect
hours-worked-evenly-flag to be true, and hence shouldAskForHoursLostFLAG to
be true as well. Am I missing something?

Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
View this message in context: http://discuss.orbeon.com/XForms-Engine-Static-XPath-Dependency-Analysis-Query-tp4659430p4659526.html
Sent from the Orbeon Forms community mailing list mailing list archive at Nabble.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Orbeon Forms" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/orbeon/Pz8kgDGqA6o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To post to this group, send email to [hidden email].

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: XForms Engine Static XPath Dependency Analysis Query

Alessandro  Vernet
Administrator
Hi Graham,

OK, I think I am seeing what it is going on. Currently, in the Orbeon XForms engine, calculations are done in the order in which the fields appear in the form. They are recalculated when a value change in an instance because a user changes that value; but they are not recalculated if a value changes because a calculation gives a new result.

Let's assume you have to fields A and B, appearing in your form, both calculated. If B depends on the value of A, then you are good; however if A depends on the value of B, then you are in trouble. So you need to either avoid having calculated fields use the value of other calculated fields, or, when that happens, make sure that the calculated fields one depends on appear before the current field in the form.

We have some thoughts on how to improve this in the following issue:

https://github.com/orbeon/orbeon-forms/issues/1192

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet