xslt.pre-processing.pogues-xml.goto-2-if-then-else.xsl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of eno-core Show documentation
Show all versions of eno-core Show documentation
Eno is a tool that generates survey questionnaires starting from their formal description in DDI
The newest version!
Created on: Jun 15, 2017
Modified on: Feb, 2018 ; Oct, 2020
Authors: Antoine Dreyer + François Bulot
This program works with 2 steps :
- the first step creates this list ($split_goto) of the Gotos to insert
- the second one inserts the IfThenElse in the existing questionnaire
The idea is that before inserting an ITE, one can define these 4 siblings :
(1) the last sibling before the ITE
(2) the first sibling inside the ITE
(3) the last sibling inside the ITE
(4) the first sibling after the ITE
Theses sibling follow these rules :
(2) and (3) must exist, but can be the same child
(1) is (2)'s first preceding sibling ; (4) is (3)'s first following sibling
(1) or (4) must exist, otherwise the parent is filtered
What defines the ITE to insert :
- its condition is the opposite of the Goto's
- it starts after (1) or before (2)
- it ends before (4) or after (3) when (3) is the last child
The list defined by the first step contains Goto with these characteristics :
- an Expression / condition
- 2 elements : "From" and "To" that designate siblings (real id or 'last' for the sibling "To")
- an attribute "start" that worth 'before' or 'after'
The second step uses a special browsing :
By default, each element calls its first child and its first following sibling
When an ITE is inserted, another following sibling (4) is called as ITE's first following sibling
and, inside the ITE, the elements are called with a stop-position = (4)
The whole input file
List of the Child (Sequence ; Question ; Loop), with position
The same list where parents contain their descendants
The template necessary to browse child-position-list and create the variable $child-tree
A value to identify the last element of any Child ; not used and greater than any existing id
A value to identify the end of the questionnaire ; not used and greater than any existing id
The list of Gotos directly from the source file
Goto's targets that are first child are replace by their parent (or first ancestor that has a preeding-sibling
list of the gotos :
- without the Gotos goning backward (it would be loops)
- with distinct From and To : the first one takes the conditions of its following-siblings
So 2 Gotos going forward with the same From and the same To become 1 with 'or' between the 2 Expressions
If 2 Gotos have the same From, To and Expression, the 2nd one is removed
This variable deals with lapping gotos:
When there are :
Goto1 : Expression : condition1 ; From : 1 ; To : 6
Goto2 : Expression : condition2 ; From : 2 ; To : 9
They become 2 Gotos and a gotoLap :
Goto1 : Expression : condition1 ; From : 1 ; To : 6
Goto2 : Expression : condition2 ; From : 2 ; To : 6 (the same as the previous Goto)
gotoLap : Expression : ((condition2) or not(condition1)) ; lap From : 6 ; To : 9
When Goto1.To (6 here) is a child inside a sequence (sequence 4 includes questions 5 to 7) and Goto2.From and Goto2.To (2 and 9 here) are out of the sequence
then the gotoLap.From is not the child (6), but the sequence (4), because Goto2 leaps over the whole sequence.
new-Goto2.To is the same value (4 instead of 6)
Goto1 : Expression : condition1 ; From : 1 ; To : 6
Goto2 : Expression : condition2 ; From : 2 ; To : 6 (no longer the same as the previous Goto : the split point has changed)
gotoLap : Expression : ((condition2) or not(condition1)) ; lap From : 4 ; To : 9
Splits Gotos which go outside a sequence or inside a sequence
Each split goto goes from an element to one of its following-sibling
TODO : go inside / outside an existing IfThenElse ; forbid go inside an existing Loop (nonsense)
the root element
every tag not containing Child can be directly copied and calls its first following-sibling, including case stop-position = $end
exception : stop-position = $last and the element is after the last child : it is the only stop case not managed by the pogues:Child template
Tags containing Child call their first child and their first following-sibling
Child : Sequence or Question
parameters :
- stop-position : first Child not to take
- goto-style (none, before, after) : with stop-position, identifies the last Goto already inserted