Skip to content

Commit

Permalink
feat(pogues2ddi): table dynamic size defined with an expression (#1117)
Browse files Browse the repository at this point in the history
* Première dimension des tableaux : refacto Pogues + tab dyn de longueur fixée par formule

- suppression de @dynamic pour les dimensions autres que PRIMARY
- @dynamic = 0 => @dynamic = NON_DYNAMIC
- @dynamic = min-max => @dynamic = DYNAMIC_LENGTH avec les éléments MinLines et MaxLines
- @dynamic = FIXED_LENGTH avec élément FixedLenth : en DDI, un élément ConditionForContinuation qui contient une formule

* chore: bump version

---------

Co-authored-by: Nicolas Senave <[email protected]>
BulotF and nsenave committed Nov 4, 2024
1 parent a3d0bf8 commit 86c6f82
Showing 7 changed files with 156 additions and 38 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@

<groupId>fr.insee.eno</groupId>
<artifactId>eno-core</artifactId>
<version>2.10.3-SNAPSHOT</version>
<version>2.11.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Eno – Questionnaire generator</name>
22 changes: 20 additions & 2 deletions src/main/resources/xslt/inputs/pogues-xml/functions.fods
Original file line number Diff line number Diff line change
@@ -728,13 +728,31 @@
</table:table-cell>
<table:table-cell table:number-columns-repeated="3"/>
</table:table-row>
<table:table-row table:style-name="ro1">
<table:table-cell table:style-name="ce20" office:value-type="string" calcext:value-type="string">
<text:p>enopogues:get-minimum-lines</text:p>
</table:table-cell>
<table:table-cell table:number-columns-repeated="2"/>
<table:table-cell office:value-type="string" calcext:value-type="string">
<text:p>Returns the minimum lines for a dynamic table</text:p>
</table:table-cell>
</table:table-row>
<table:table-row table:style-name="ro1">
<table:table-cell table:style-name="ce20" office:value-type="string" calcext:value-type="string">
<text:p>enopogues:get-maximum-lines</text:p>
</table:table-cell>
<table:table-cell table:number-columns-repeated="2"/>
<table:table-cell office:value-type="string" calcext:value-type="string">
<text:p>Returns the maximum lines for a dynamic table</text:p>
</table:table-cell>
</table:table-row>
<table:table-row table:style-name="ro2">
<table:table-cell table:style-name="ce21" office:value-type="string" calcext:value-type="string">
<text:p>enopogues:get-dynamic</text:p>
<text:p>enopogues:get-fixed-lines</text:p>
</table:table-cell>
<table:table-cell table:number-columns-repeated="2"/>
<table:table-cell table:style-name="ce24" office:value-type="string" calcext:value-type="string">
<text:p>Return the dynamic attribute of the pogues:Dimension. This value is used to compute positions in grids</text:p>
<text:p>Returns the formula for the fixed number of lines for a dynamic table</text:p>
</table:table-cell>
</table:table-row>
<table:table-row table:style-name="ro1">
10 changes: 5 additions & 5 deletions src/main/resources/xslt/inputs/pogues-xml/source-fixed.xsl
Original file line number Diff line number Diff line change
@@ -214,12 +214,13 @@
</xsl:choose>
</xsl:template>

<xsl:template match="pogues:Expression | pogues:Formula | pogues:Response | pogues:Maximum[parent::pogues:Loop] | pogues:Minimum[parent::pogues:Loop] | pogues:Filter[parent::pogues:Loop]" mode="enopogues:get-ip-id">
<xsl:template match="pogues:Expression | pogues:Formula | pogues:Response | pogues:Maximum[parent::pogues:Loop] | pogues:Minimum[parent::pogues:Loop] | pogues:Filter[parent::pogues:Loop] | pogues:FixedLength" mode="enopogues:get-ip-id">
<xsl:param name="index" tunnel="yes"/>
<xsl:choose>
<xsl:when test="name() = 'Minimum'"><xsl:value-of select="concat(enopogues:get-id(parent::pogues:Loop), '-MIN-IP-', $index)"/></xsl:when>
<xsl:when test="name() = 'Maximum'"><xsl:value-of select="concat(enopogues:get-id(parent::pogues:Loop), '-IP-', $index)"/></xsl:when>
<xsl:when test="name() = 'Filter'"><xsl:value-of select="concat(enopogues:get-id(parent::pogues:Loop), '-ITE-IP-', $index)"/></xsl:when>
<xsl:when test="name() = 'FixedLength'"><xsl:value-of select="concat(enopogues:get-id(parent::pogues:Dimension/parent::pogues:ResponseStructure/parent::pogues:Child), '-DIM1-ITE-IP-', $index)"/></xsl:when>
<xsl:otherwise><xsl:value-of select="concat(enopogues:get-id(.), '-IP-', $index)"/></xsl:otherwise>
</xsl:choose>
</xsl:template>
@@ -235,7 +236,7 @@
<xsl:sequence select="//pogues:Variable[@id = $idVariable]"/>
</xsl:template>

<xsl:template match="pogues:Expression | pogues:Formula | pogues:Text | pogues:Control/pogues:FailMessage | pogues:Label | pogues:Loop/pogues:Maximum | pogues:Loop/pogues:Minimum | pogues:Loop/pogues:Filter | pogues:OccurrenceLabel | pogues:OccurrenceDescription | pogues:Unit" mode="enopogues:get-related-variable">
<xsl:template match="pogues:Expression | pogues:Formula | pogues:Text | pogues:Control/pogues:FailMessage | pogues:Label | pogues:Loop/pogues:Maximum | pogues:Loop/pogues:Minimum | pogues:Loop/pogues:Filter | pogues:OccurrenceLabel | pogues:OccurrenceDescription | pogues:Unit | pogues:FixedLength" mode="enopogues:get-related-variable">
<xsl:variable name="expressionVariable" select="tokenize(., '\$')"/>
<xsl:variable name="variables" select="//pogues:Variables"/>

@@ -268,7 +269,6 @@
mode="enopogues:get-fake-dimension">
<xsl:element name="pogues:Dimension">
<xsl:attribute name="dimensionType" select="'SECONDARY'"/>
<xsl:attribute name="dynamic" select="0"/>
<xsl:element name="pogues:CodeListReference">
<xsl:value-of select="enopogues:get-fake-code-list-id(.)"/>
</xsl:element>
@@ -285,7 +285,7 @@
<pogues:CodeList id="{enopogues:get-fake-code-list-id(.)}">
<pogues:Name/>
<pogues:Label><xsl:value-of select="concat('FAKE-CODELIST-',enopogues:get-fake-code-list-id(.))"/></pogues:Label>
<xsl:for-each select="pogues:Dimension[@dimensionType='MEASURE' and @dynamic='0']">
<xsl:for-each select="pogues:Dimension[@dimensionType='MEASURE']">
<pogues:Code>
<pogues:Value><xsl:value-of select="position()"/></pogues:Value>
<pogues:Label><xsl:value-of select="enopogues:get-label(.)"/></pogues:Label>
@@ -302,7 +302,7 @@
select="concat($context/parent::pogues:Child/@id, '-secondDimension-fakeCL-1')"/>
</xsl:function>

<xsl:template match="pogues:Declaration/pogues:Text | pogues:Control/pogues:FailMessage | pogues:Label | pogues:OccurrenceLabel | pogues:OccurrenceDescription | pogues:Unit[../pogues:IsDynamicUnit='true']" mode="id-variable">
<xsl:template match="pogues:Declaration/pogues:Text | pogues:Control/pogues:FailMessage | pogues:Label | pogues:OccurrenceLabel | pogues:OccurrenceDescription | pogues:Unit[../pogues:IsDynamicUnit='true'] | pogues:FixedLength" mode="id-variable">
<xsl:variable name="variables" select="enopogues:get-related-variable(.)"/>
<xsl:choose>
<xsl:when test="$variables">
82 changes: 72 additions & 10 deletions src/main/resources/xslt/inputs/pogues-xml/templates.fods
Original file line number Diff line number Diff line change
@@ -819,17 +819,79 @@
</table:table-row>
<table:table-row table:style-name="ro2">
<table:table-cell office:value-type="string" calcext:value-type="string">
<text:p>pogues:Dimension</text:p>
<text:p>pogues:Dimension[contains(@dynamic,&apos;-&apos;)]</text:p>
</table:table-cell>
<table:table-cell table:style-name="ce2" office:value-type="string" calcext:value-type="string">
<text:p>enopogues:get-minimum-lines</text:p>
</table:table-cell>
<table:table-cell office:value-type="string" calcext:value-type="string">
<text:p>enopogues:get-dynamic</text:p>
<text:p>substring-before(@dynamic, &apos;-&apos;)</text:p>
</table:table-cell>
<table:table-cell/>
<table:table-cell table:style-name="ce1" office:value-type="string" calcext:value-type="string">
<text:p>Returns the minimum lines for a dynamic table (old version)</text:p>
</table:table-cell>
</table:table-row>
<table:table-row table:style-name="ro2">
<table:table-cell office:value-type="string" calcext:value-type="string">
<text:p>@dynamic</text:p>
<text:p>pogues:Dimension[contains(@dynamic,&apos;-&apos;)]</text:p>
</table:table-cell>
<table:table-cell table:style-name="ce2" office:value-type="string" calcext:value-type="string">
<text:p>enopogues:get-maximum-lines</text:p>
</table:table-cell>
<table:table-cell office:value-type="string" calcext:value-type="string">
<text:p>substring-after(@dynamic, &apos;-&apos;)</text:p>
</table:table-cell>
<table:table-cell/>
<table:table-cell table:style-name="ce1" office:value-type="string" calcext:value-type="string">
<text:p>Returns the maximum lines for a dynamic table (old version)</text:p>
</table:table-cell>
</table:table-row>
<table:table-row table:style-name="ro2">
<table:table-cell office:value-type="string" calcext:value-type="string">
<text:p>pogues:Dimension[@dynamic=&apos;DYNAMIC_LENGTH&apos;]</text:p>
</table:table-cell>
<table:table-cell table:style-name="ce2" office:value-type="string" calcext:value-type="string">
<text:p>enopogues:get-minimum-lines</text:p>
</table:table-cell>
<table:table-cell office:value-type="string" calcext:value-type="string">
<text:p>Return the dynamic attribute of the pogues:Dimension. This value is used to compute positions in grids</text:p>
<text:p>pogues:MinLines</text:p>
</table:table-cell>
<table:table-cell/>
<table:table-cell table:style-name="ce1" office:value-type="string" calcext:value-type="string">
<text:p>Returns the minimum lines for a dynamic table (new version)</text:p>
</table:table-cell>
</table:table-row>
<table:table-row table:style-name="ro2">
<table:table-cell office:value-type="string" calcext:value-type="string">
<text:p>pogues:Dimension[@dynamic=&apos;DYNAMIC_LENGTH&apos;]</text:p>
</table:table-cell>
<table:table-cell table:style-name="ce2" office:value-type="string" calcext:value-type="string">
<text:p>enopogues:get-maximum-lines</text:p>
</table:table-cell>
<table:table-cell office:value-type="string" calcext:value-type="string">
<text:p>pogues:MaxLines</text:p>
</table:table-cell>
<table:table-cell/>
<table:table-cell table:style-name="ce1" office:value-type="string" calcext:value-type="string">
<text:p>Returns the maximum lines for a dynamic table (new version)</text:p>
</table:table-cell>
</table:table-row>
<table:table-row table:style-name="ro2">
<table:table-cell office:value-type="string" calcext:value-type="string">
<text:p>pogues:Dimension[@dynamic=&apos;FIXED_LENGTH&apos;]</text:p>
</table:table-cell>
<table:table-cell table:style-name="ce3" office:value-type="string" calcext:value-type="string">
<text:p>enopogues:get-fixed-lines</text:p>
</table:table-cell>
<table:table-cell office:value-type="string" calcext:value-type="string">
<text:p>pogues:FixedLength</text:p>
</table:table-cell>
<table:table-cell office:value-type="string" calcext:value-type="string">
<text:p>with-tag</text:p>
</table:table-cell>
<table:table-cell table:style-name="ce5" office:value-type="string" calcext:value-type="string">
<text:p>Returns the formula for the fixed number of lines for a dynamic table</text:p>
</table:table-cell>
</table:table-row>
<table:table-row table:style-name="ro2">
@@ -1808,7 +1870,7 @@
</table:table-row>
<table:table-row table:style-name="ro2">
<table:table-cell office:value-type="string" calcext:value-type="string">
<text:p>pogues:Child[@questionType=&apos;TABLE&apos; and not(pogues:ResponseStructure/pogues:Dimension[@dimensionType=&quot;PRIMARY&quot; and @dynamic != &apos;0&apos;])]</text:p>
<text:p>pogues:Child[@questionType=&apos;TABLE&apos; and not(pogues:ResponseStructure/pogues:Dimension[@dimensionType=&quot;PRIMARY&quot; and (@dynamic != &apos;0&apos; and @dynamic != &apos;NON_DYNAMIC&apos;)])]</text:p>
</table:table-cell>
<table:table-cell office:value-type="string" calcext:value-type="string">
<text:p>enopogues:get-type</text:p>
@@ -1823,7 +1885,7 @@
</table:table-row>
<table:table-row table:style-name="ro2">
<table:table-cell office:value-type="string" calcext:value-type="string">
<text:p>pogues:Child[@questionType=&apos;TABLE&apos; and pogues:ResponseStructure/pogues:Dimension[@dimensionType=&quot;PRIMARY&quot; and @dynamic != &apos;0&apos;]]</text:p>
<text:p>pogues:Child[@questionType=&apos;TABLE&apos; and pogues:ResponseStructure/pogues:Dimension[@dimensionType=&quot;PRIMARY&quot; and @dynamic != &apos;0&apos; and @dynamic != &apos;NON_DYNAMIC&apos;]]</text:p>
</table:table-cell>
<table:table-cell office:value-type="string" calcext:value-type="string">
<text:p>enopogues:get-type</text:p>
@@ -2160,7 +2222,7 @@
</table:table-row>
<table:table-row table:style-name="ro2">
<table:table-cell office:value-type="string" calcext:value-type="string">
<text:p>pogues:Variable[@xsi:type=&apos;CollectedVariableType&apos; and (not(pogues:Scope) or pogues:Scope=&apos;&apos;) and //pogues:Child[pogues:Response/pogues:CollectedVariableReference=current()/@id][pogues:ResponseStructure/pogues:Dimension[@dimensionType=&quot;PRIMARY&quot; and @dynamic != &apos;0&apos;]]]</text:p>
<text:p>pogues:Variable[@xsi:type=&apos;CollectedVariableType&apos; and (not(pogues:Scope) or pogues:Scope=&apos;&apos;) and //pogues:Child[pogues:Response/pogues:CollectedVariableReference=current()/@id][pogues:ResponseStructure/pogues:Dimension[@dimensionType=&quot;PRIMARY&quot; and @dynamic != &apos;0&apos; and @dynamic != &apos;NON_DYNAMIC&apos;]]]</text:p>
</table:table-cell>
<table:table-cell office:value-type="string" calcext:value-type="string">
<text:p>enopogues:get-variable-group</text:p>
@@ -2175,7 +2237,7 @@
</table:table-row>
<table:table-row table:style-name="ro2">
<table:table-cell office:value-type="string" calcext:value-type="string">
<text:p>pogues:Variable[@xsi:type=&apos;CollectedVariableType&apos; and (not(pogues:Scope) or pogues:Scope=&apos;&apos;) and //pogues:Child[pogues:Response/pogues:CollectedVariableReference=current()/@id][not(pogues:ResponseStructure/pogues:Dimension[@dimensionType=&quot;PRIMARY&quot; and @dynamic != &apos;0&apos;]) and not(@questionType=&apos;PAIRWISE&apos;)]]</text:p>
<text:p>pogues:Variable[@xsi:type=&apos;CollectedVariableType&apos; and (not(pogues:Scope) or pogues:Scope=&apos;&apos;) and //pogues:Child[pogues:Response/pogues:CollectedVariableReference=current()/@id][not(pogues:ResponseStructure/pogues:Dimension[@dimensionType=&quot;PRIMARY&quot; and @dynamic != &apos;0&apos; and @dynamic != &apos;NON_DYNAMIC&apos;]) and not(@questionType=&apos;PAIRWISE&apos;)]]</text:p>
</table:table-cell>
<table:table-cell office:value-type="string" calcext:value-type="string">
<text:p>enopogues:get-variable-group</text:p>
@@ -2190,7 +2252,7 @@
</table:table-row>
<table:table-row table:style-name="ro2">
<table:table-cell office:value-type="string" calcext:value-type="string">
<text:p>pogues:Variable[@xsi:type=&apos;CollectedVariableType&apos; and (not(pogues:Scope) or pogues:Scope=&apos;&apos;) and //pogues:Child[pogues:ClarificationQuestion//pogues:CollectedVariableReference=current()/@id][not(pogues:ResponseStructure/pogues:Dimension[@dimensionType=&quot;PRIMARY&quot; and @dynamic != &apos;0&apos;])]]</text:p>
<text:p>pogues:Variable[@xsi:type=&apos;CollectedVariableType&apos; and (not(pogues:Scope) or pogues:Scope=&apos;&apos;) and //pogues:Child[pogues:ClarificationQuestion//pogues:CollectedVariableReference=current()/@id][not(pogues:ResponseStructure/pogues:Dimension[@dimensionType=&quot;PRIMARY&quot; and @dynamic != &apos;0&apos; and @dynamic != &apos;NON_DYNAMIC&apos;])]]</text:p>
</table:table-cell>
<table:table-cell office:value-type="string" calcext:value-type="string">
<text:p>enopogues:get-variable-group</text:p>
@@ -2318,7 +2380,7 @@
</table:table-row>
<table:table-row table:style-name="ro2">
<table:table-cell office:value-type="string" calcext:value-type="string">
<text:p>pogues:Child[@xsi:type=&apos;QuestionType&apos; and @questionType=&apos;TABLE&apos; and pogues:ResponseStructure/pogues:Dimension[@dimensionType=&apos;PRIMARY&apos; and @dynamic != &apos;0&apos;]]</text:p>
<text:p>pogues:Child[@xsi:type=&apos;QuestionType&apos; and @questionType=&apos;TABLE&apos; and pogues:ResponseStructure/pogues:Dimension[@dimensionType=&apos;PRIMARY&apos; and @dynamic != &apos;0&apos; and @dynamic != &apos;NON_DYNAMIC&apos;]]</text:p>
</table:table-cell>
<table:table-cell office:value-type="string" calcext:value-type="string">
<text:p>enopogues:get-scope-loops</text:p>
30 changes: 22 additions & 8 deletions src/main/resources/xslt/outputs/ddi/models.xsl
Original file line number Diff line number Diff line change
@@ -1426,7 +1426,7 @@
<xsl:variable name="result">
<xsl:choose>
<!-- Calling the specifc template to handle CommandContent when in regular Command case. -->
<xsl:when test="self::Command or ancestor-or-self::IfThenElse or self::Loop">
<xsl:when test="self::Command or ancestor-or-self::IfThenElse or self::Loop or self::RosterDimension">
<xsl:call-template name="replace-pogues-name-variable-by-ddi-id-ip">
<xsl:with-param name="expression" select="concat($source-context,' ')"/>
<xsl:with-param name="current-variable-with-id" select="$related-variables-with-id/*[1]"/>
@@ -1443,7 +1443,7 @@
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="contains($result,'-ITE-IP-')"><xsl:value-of select="concat('not(',normalize-space($result),')')"/></xsl:when>
<xsl:when test="contains($result,'-ITE-IP-') and not(self::RosterDimension)"><xsl:value-of select="concat('not(',normalize-space($result),')')"/></xsl:when>
<xsl:otherwise><xsl:value-of select="normalize-space($result)"/></xsl:otherwise>
</xsl:choose>
</r:CommandContent>
@@ -2423,12 +2423,26 @@
<xsl:param name="source-context" as="item()" tunnel="yes"/>
<d:GridDimension displayCode="false" displayLabel="false" rank="{enoddi33:get-rank($source-context)}">
<d:Roster baseCodeValue="1" codeIterationValue="1">
<xsl:attribute name="minimumRequired">
<xsl:value-of select="substring-before(enoddi33:get-dynamic($source-context), '-')"/>
</xsl:attribute>
<xsl:attribute name="maximumAllowed">
<xsl:value-of select="substring-after(enoddi33:get-dynamic($source-context), '-')"/>
</xsl:attribute>
<xsl:variable name="minimumRequired" select="enoddi33:get-minimum-lines($source-context)"/>
<xsl:variable name="maximumAllowed" select="enoddi33:get-maximum-lines($source-context)"/>
<xsl:variable name="ConditionForContinuation" select="enoddi33:get-fixed-lines($source-context)"/>
<xsl:if test="$minimumRequired != ''">
<xsl:attribute name="minimumRequired">
<xsl:value-of select="$minimumRequired"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$maximumAllowed != ''">
<xsl:attribute name="maximumAllowed">
<xsl:value-of select="$maximumAllowed"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$ConditionForContinuation != ''">
<d:ConditionForContinuation>
<xsl:call-template name="Command">
<xsl:with-param name="source-context" tunnel="yes" select="$ConditionForContinuation"/>
</xsl:call-template>
</d:ConditionForContinuation>
</xsl:if>
</d:Roster>
</d:GridDimension>
</xsl:template>
Loading

0 comments on commit 86c6f82

Please sign in to comment.