Skip to content

Commit

Permalink
Merge pull request #64 from ath-dhm/develop
Browse files Browse the repository at this point in the history
Workaround for suggesters and rules tag of field
  • Loading branch information
bwerquin authored Nov 25, 2021
2 parents f698353 + 8c2e9b8 commit 20b043d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>fr.insee.lunatic</groupId>
<artifactId>lunatic-model</artifactId>
<packaging>jar</packaging>
<version>2.2.7</version>
<version>2.2.8</version>
<name>Lunatic Model</name>
<description>Classes and converters for the Lunatic model</description>
<url>http://www.insee.fr</url>
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/xsd/LunaticModel.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@
<xs:complexType name="SuggesterField">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="rules" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
<xs:choice>
<xs:element name="rules" type="xs:string"/>
<xs:element name="rulesA" type="xs:string" minOccurs="1" maxOccurs="unbounded"/>
</xs:choice>
<xs:element name="language" type="xs:string" minOccurs="0"/>
<xs:element name="min" type="xs:integer" minOccurs="0"/>
<xs:element name="stemmer" type="xs:boolean" minOccurs="0"/>
Expand Down
7 changes: 5 additions & 2 deletions src/main/resources/xsd/LunaticModelFlat.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,11 @@
<xs:complexType name="SuggesterField">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="rules" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="language" type="xs:string" minOccurs="0"/>
<xs:choice>
<xs:element name="rules" type="xs:string"/>
<xs:element name="rulesA" type="xs:string" minOccurs="1" maxOccurs="unbounded"/>
</xs:choice>
<xs:element name="language" type="xs:string" minOccurs="0"/>
<xs:element name="min" type="xs:integer" minOccurs="0"/>
<xs:element name="stemmer" type="xs:boolean" minOccurs="0"/>
<xs:element name="synonyms" type="FieldSynonym" minOccurs="0" maxOccurs="unbounded"/>
Expand Down
10 changes: 9 additions & 1 deletion src/main/resources/xslt/json-cleaner.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<xsl:template match="*[local-name(.)='map'][parent::*[@key='value' and local-name(.)='array'] or (self::*[@key='value'] and preceding-sibling::*[@key='variableType'])]" mode="clean">
<xsl:apply-templates mode="clean"/>
</xsl:template>
<!-- delete key attribue for array inside array -->
<!-- delete key attribute for array inside array -->
<xsl:template match="*[local-name(.)='array' and @key=('PREVIOUS','COLLECTED','FORCED','EDITED','INPUTED','value')][ancestor::*[local-name(.)='array' and @key=('PREVIOUS','COLLECTED','FORCED','EDITED','INPUTED','value')]]" mode="clean">
<xsl:copy>
<xsl:apply-templates mode="clean"/>
Expand All @@ -50,6 +50,14 @@
</xsl:copy>
</xsl:template>

<!-- rename the rulesA key of suggesters to rules -->
<xsl:template match="*[@key='rulesA']" mode="clean">
<xsl:copy>
<xsl:attribute name="key" select="'rules'"/>
<xsl:apply-templates select="node()" mode="clean"/>
</xsl:copy>
</xsl:template>

<xsl:template match="@*|node()" mode="clean">
<xsl:choose>
<xsl:when test="self::text()">
Expand Down

0 comments on commit 20b043d

Please sign in to comment.