Reputation: 23
I am working on Orbeon forms and i have a functionality related issue as explained below. I have a form which has repeat fields as below which is to be added dynamically by clicking on 'Add' button. I have two fields in the repeat section.And also i have a condition like the fields must be compared with the one in the same row and also with the one which is in the previous and also in the next row.
I have an instance like this:
1.constraint="if(.!='')
then
(. < ../two and . > ../preceding::number/two)
else
true()"/>
2.constraint="if(.!='' )
then
(. > ../one and . < ../following-sibling::number/one)
else
true()"/>
<number> is under repeat condition.
1.In this,i am trying to compare number/one with <two> in the same row and the preceding row.
2.In this,i am trying to compare number/two with <one> in the same row and the next preceding row.
I have to add like 10 times of these fields.When it is added after 3rd time,the logic doesn't work properly.
Kindly let me know what happens in this case.
Upvotes: 2
Views: 419
Reputation: 274
Unqualified preceding-sibling and following-sibling xpath expressions return a sequence of all preceding or following siblings.
You need to add a predicate to select the previous or next sibling.
So, for your example:
../preceding-sibling::number[1]/two
or. more fully
../preceding-sibling::number[position()=1]/two
will return the previous sibling "two" element.
An example integer comparison:
(. > xs:integer(../preceding-sibling::number[1]/two))
See http://blog.orbeon.com/2007/06/xpath-reverse-axis-evil-at-times_04.html for more.
Regards
Jez
Upvotes: 3