-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: valueOverrides in the translation profiles can now also be appl…
…ied to case roles
- Loading branch information
1 parent
babe98b
commit 17e9371
Showing
11 changed files
with
561 additions
and
330 deletions.
There are no files selected for viewing
125 changes: 0 additions & 125 deletions
125
src/main/configurations/Translate/Common/xsl/ApplyValueOverrides.xsl
This file was deleted.
Oops, something went wrong.
107 changes: 107 additions & 0 deletions
107
src/main/configurations/Translate/Common/xsl/ApplyValueOverrides.xslt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<xsl:stylesheet version="3.0" exclude-result-prefixes="#all" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:map="http://www.w3.org/2005/xpath-functions/map" xmlns:array="http://www.w3.org/2005/xpath-functions/array"> | ||
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes" /> | ||
<xsl:strip-space elements="*"/> | ||
|
||
<xsl:param name="valueOverrides" as="node()?"><xsl:document><root /></xsl:document></xsl:param> | ||
<xsl:param name="mergeWith" as="node()?"><xsl:document /></xsl:param> | ||
<xsl:param name="defaultMergeCondition" as="xs:string">string-length(.) = 0</xsl:param> | ||
<xsl:param name="processAsArrayKeys" select="''" as="xs:string" /> | ||
|
||
<xsl:param name="debug" as="xs:string" select="'false'" /> | ||
<xsl:variable name="debugSerializeParams" as="map(xs:string, item()?)"> | ||
<xsl:map> | ||
<xsl:map-entry key="'indent'" select="true()"/> | ||
</xsl:map> | ||
</xsl:variable> | ||
|
||
<xsl:key name="valueOverrideKey" match="valueOverrides" use="key" /> | ||
|
||
<xsl:template match="/"> | ||
<xsl:if test="$debug = 'true'"><xsl:if test="$debug = 'true'"><xsl:comment expand-text="yes"> input context: [{serialize(/, $debugSerializeParams)}] </xsl:comment></xsl:if></xsl:if> | ||
<xsl:if test="$debug = 'true'"><xsl:comment expand-text="yes"> mergeWith context: [{serialize($mergeWith, $debugSerializeParams)}] </xsl:comment></xsl:if> | ||
<xsl:call-template name="merge"> | ||
<xsl:with-param name="inputContext" select="/" /> | ||
<xsl:with-param name="valueOverridesContext" select="$mergeWith" /> | ||
<xsl:with-param name="valueOverrideKey" select="''" /> | ||
</xsl:call-template> | ||
</xsl:template> | ||
|
||
<xsl:template name="merge"> | ||
<xsl:param name="inputContext" /> | ||
<xsl:param name="valueOverridesContext" /> | ||
<xsl:param name="valueOverrideKey" as="xs:string" /> | ||
<xsl:merge> | ||
<xsl:merge-source name="inputContext" sort-before-merge="yes" for-each-item="$inputContext" select="*" > | ||
<xsl:merge-key select="local-name()" exclude-result-prefixes="#all" /> | ||
</xsl:merge-source> | ||
<xsl:merge-source name="valueOverridesContext" sort-before-merge="yes" for-each-item="$valueOverridesContext" select="*"> | ||
<xsl:merge-key select="local-name()" exclude-result-prefixes="#all" /> | ||
</xsl:merge-source> | ||
<xsl:merge-action> | ||
<xsl:if test="$debug = 'true'"><xsl:comment expand-text="yes"> current-merge-key: [{serialize(current-merge-key(), $debugSerializeParams)}] </xsl:comment></xsl:if> | ||
<xsl:if test="$debug = 'true'"><xsl:comment expand-text="yes"> current-merge-group: [{serialize(current-merge-group(), $debugSerializeParams)}] </xsl:comment></xsl:if> | ||
|
||
<xsl:variable name="currentValueOverrideKey" select="if ($valueOverrideKey != '') then concat($valueOverrideKey, '.', current-merge-key()) else current-merge-key()" /> | ||
<xsl:if test="$debug = 'true'"><xsl:comment expand-text="yes"> currentValueOverrideKey: [{serialize($currentValueOverrideKey, $debugSerializeParams)}] </xsl:comment></xsl:if> | ||
|
||
<xsl:variable name="valueOverride" select="key('valueOverrideKey', $currentValueOverrideKey, $valueOverrides)" /> | ||
<xsl:if test="$debug = 'true'"><xsl:comment expand-text="yes"> valueOverride: [{serialize($valueOverride, $debugSerializeParams)}] </xsl:comment></xsl:if> | ||
|
||
<xsl:choose> | ||
<xsl:when test="tokenize($processAsArrayKeys, ',') = $currentValueOverrideKey"> | ||
<xsl:if test="$debug = 'true'"><xsl:comment> merge-action-route: [processAsArray bypass] </xsl:comment></xsl:if> | ||
|
||
<xsl:copy-of select="current-merge-group('inputContext')" /> | ||
<xsl:copy-of select="current-merge-group('valueOverridesContext')" /> | ||
</xsl:when> | ||
<xsl:when test="current-merge-group('inputContext')/* or current-merge-group('valueOverridesContext')/*"> | ||
<xsl:if test="$debug = 'true'"><xsl:comment> merge-action-route: [merge children] </xsl:comment></xsl:if> | ||
|
||
<xsl:element name="{current-merge-key()}"> | ||
<xsl:call-template name="merge"> | ||
<xsl:with-param name="inputContext" select="current-merge-group('inputContext')" /> | ||
<xsl:with-param name="valueOverridesContext" select="current-merge-group('valueOverridesContext')" /> | ||
<xsl:with-param name="valueOverrideKey" select="$currentValueOverrideKey" /> | ||
</xsl:call-template> | ||
</xsl:element> | ||
</xsl:when> | ||
<xsl:when test="current-merge-group('valueOverridesContext')"> | ||
<xsl:if test="$debug = 'true'"><xsl:comment> merge-action-route: [process valueOverride] </xsl:comment></xsl:if> | ||
|
||
<xsl:variable name="valueOverrideCondition" select="if ($valueOverride/condition) then $valueOverride/condition else $defaultMergeCondition" /> | ||
<xsl:if test="$debug = 'true'"><xsl:comment expand-text="yes"> resolvedValueOverrideCondition: [{serialize($valueOverrideCondition, $debugSerializeParams)}] </xsl:comment></xsl:if> | ||
|
||
<xsl:variable name="contextItem"> | ||
<xsl:choose> | ||
<xsl:when test="current-merge-group('inputContext')"> | ||
<xsl:copy-of select="current-merge-group('inputContext')" /> | ||
</xsl:when> | ||
<xsl:otherwise><emptyContextItem/></xsl:otherwise> | ||
</xsl:choose> | ||
</xsl:variable> | ||
<xsl:if test="$debug = 'true'"><xsl:comment expand-text="yes"> context-item: [{serialize($contextItem, $debugSerializeParams)}] </xsl:comment></xsl:if> | ||
|
||
<xsl:variable name="valueOverrideConditionResult" as="xs:boolean"><xsl:value-of><xsl:evaluate xpath="$valueOverrideCondition" context-item="$contextItem" as="xs:boolean" /></xsl:value-of></xsl:variable> | ||
<xsl:if test="$debug = 'true'"><xsl:comment expand-text="yes"> evaluateConditionResult: [{serialize($valueOverrideConditionResult, $debugSerializeParams)}] </xsl:comment></xsl:if> | ||
|
||
<xsl:choose> | ||
<xsl:when test="$valueOverrideConditionResult = true()"> | ||
<xsl:if test="$debug = 'true'"><xsl:comment> evaluateConditionResult: [true], using merge-group: [valueOverridesContext] </xsl:comment></xsl:if> | ||
<xsl:copy-of select="current-merge-group('valueOverridesContext')" /> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:if test="$debug = 'true'"><xsl:comment> evaluateConditionResult: [false], using merge-group: [inputContext] </xsl:comment></xsl:if> | ||
<xsl:copy-of select="current-merge-group('inputContext')" /> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:if test="$debug = 'true'"><xsl:comment> merge-action-route: [inputContext value] </xsl:comment></xsl:if> | ||
|
||
<xsl:copy-of select="current-merge-group('inputContext')" /> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</xsl:merge-action> | ||
</xsl:merge> | ||
</xsl:template> | ||
</xsl:stylesheet> |
31 changes: 31 additions & 0 deletions
31
src/main/configurations/Translate/Common/xsl/FilterValueOverridesOnKeyRoot.xslt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<xsl:stylesheet version="3.0" exclude-result-prefixes="#all" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:map="http://www.w3.org/2005/xpath-functions/map" xmlns:array="http://www.w3.org/2005/xpath-functions/array"> | ||
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes" exclude-result-prefixes="#all" /> | ||
<xsl:strip-space elements="*"/> | ||
|
||
<xsl:param name="valueOverrideKeyRoot" select="''" as="xs:string" /> | ||
|
||
<xsl:template match="@*|node()"> | ||
<xsl:copy> | ||
<xsl:apply-templates select="@*|node()"/> | ||
</xsl:copy> | ||
</xsl:template> | ||
|
||
<xsl:template match="/"> | ||
<xsl:apply-templates /> | ||
</xsl:template> | ||
|
||
<xsl:template match="valueOverrides[starts-with(key, $valueOverrideKeyRoot)]"> | ||
<valueOverrides> | ||
<xsl:apply-templates /> | ||
</valueOverrides> | ||
</xsl:template> | ||
|
||
<xsl:template match="key"> | ||
<xsl:variable name="rootElementName" select="tokenize($valueOverrideKeyRoot, '\.')[last()]" /> | ||
<xsl:variable name="valueOverrideKeyBeforeRoot" select="substring-before($valueOverrideKeyRoot, concat('.', $rootElementName))" /> | ||
|
||
<key><xsl:value-of select="substring-after(current(), concat($valueOverrideKeyBeforeRoot, '.'))" /></key> | ||
</xsl:template> | ||
|
||
<xsl:template match="valueOverrides" /> | ||
</xsl:stylesheet> |
28 changes: 28 additions & 0 deletions
28
src/main/configurations/Translate/Common/xsl/LookupProcessAsArrayKeys.xslt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" /> | ||
<xsl:strip-space elements="*" /> | ||
|
||
<xsl:param name="ValueOverrideKeyRoot" select="''" as="xs:string" /> | ||
|
||
<xsl:template match="/"> | ||
<xsl:choose> | ||
<xsl:when test="$ValueOverrideKeyRoot = 'zgw.zaken-api.zaken.zaak'"> | ||
ZgwZaak.productenOfDiensten, | ||
ZgwZaak.zaakgeometrie.coordinates, | ||
ZgwZaak.relevanteAndereZaken, | ||
ZgwZaak.kenmerken, | ||
ZgwZaak.deelzaken, | ||
ZgwZaak.eigenschappen, | ||
ZgwZaak.rollen, | ||
ZgwZaak.zaakinformatieobjecten, | ||
ZgwZaak.zaakobjecten | ||
</xsl:when> | ||
<xsl:when test="$ValueOverrideKeyRoot = 'zgw.zaken-api.rollen.rol'"> | ||
zgwRol.statussen | ||
zgwRol.betrokkeneIdentificatie.handelsnaam | ||
</xsl:when> | ||
<xsl:otherwise /> | ||
</xsl:choose> | ||
</xsl:template> | ||
</xsl:stylesheet> |
63 changes: 63 additions & 0 deletions
63
src/main/configurations/Translate/Common/xsl/ValueOverridesDepthFirstUnflatten.xslt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<xsl:stylesheet version="3.0" exclude-result-prefixes="#all" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:map="http://www.w3.org/2005/xpath-functions/map" xmlns:array="http://www.w3.org/2005/xpath-functions/array"> | ||
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes" exclude-result-prefixes="#all" /> | ||
<xsl:strip-space elements="*"/> | ||
|
||
<xsl:param name="valueOverrides" as="node()?" /> | ||
|
||
<xsl:key name="valueOverrideKey" match="valueOverrides" use="key" /> | ||
|
||
<xsl:template match="/"> | ||
<xsl:variable name="tokenizedKeys"> | ||
<xsl:for-each select="$valueOverrides//valueOverrides"> | ||
<key> | ||
<xsl:for-each select="tokenize(key, '\.')"> | ||
<segment><xsl:value-of select="." /></segment> | ||
</xsl:for-each> | ||
</key> | ||
</xsl:for-each> | ||
</xsl:variable> | ||
<!-- <tokenizedKeys><xsl:copy-of select="$tokenizedKeys" /></tokenizedKeys> --> | ||
<xsl:call-template name="depthFirstUnflatten"> | ||
<xsl:with-param name="tokenizedKeys" select="$tokenizedKeys" /> | ||
<xsl:with-param name="key" select="''"/> | ||
</xsl:call-template> | ||
</xsl:template> | ||
|
||
<xsl:template name="depthFirstUnflatten"> | ||
<xsl:param name="tokenizedKeys"/> | ||
<xsl:param name="key" as="xs:string" /> | ||
<!-- <tokenizedKeys><xsl:value-of select="$tokenizedKeys" /></tokenizedKeys> --> | ||
<!-- <distinctKeys><xsl:value-of select="distinct-values($tokenizedKeys/key/segment[position() = 1])" /></distinctKeys> --> | ||
<xsl:for-each select="distinct-values($tokenizedKeys/key/segment[position() = 1])"> | ||
<xsl:variable name="ElementName" select="current()" /> | ||
<!-- <elementName><xsl:value-of select="$ElementName" /></elementName> --> | ||
<xsl:variable name="overrideKey" select="if ($key != '') then concat($key, '.', $ElementName) else $ElementName" /> | ||
<!-- <overrideKey><xsl:value-of select="$overrideKey" /></overrideKey> --> | ||
<!-- <segmentCount><xsl:value-of select="count($tokenizedKeys/key[segment[1] = $ElementName]/segment)" /></segmentCount> --> | ||
<xsl:element name="{current()}"> | ||
<xsl:choose> | ||
<xsl:when test="count($tokenizedKeys/key[segment[1] = $ElementName]/segment) gt 1"> | ||
<xsl:variable name="tokenizedKeys2"> | ||
<xsl:for-each select="$tokenizedKeys/key[segment[1] = $ElementName]"> | ||
<key> | ||
<xsl:for-each select="segment[position() gt 1]"> | ||
<xsl:copy-of select="." /> | ||
</xsl:for-each> | ||
</key> | ||
</xsl:for-each> | ||
</xsl:variable> | ||
<!-- <tokenizedKeys2><xsl:copy-of select="$tokenizedKeys2" /></tokenizedKeys2> --> | ||
<xsl:call-template name="depthFirstUnflatten"> | ||
<xsl:with-param name="tokenizedKeys" select="$tokenizedKeys2"/> | ||
<xsl:with-param name="key" select="$overrideKey"/> | ||
</xsl:call-template> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:variable name="overrideValue" select="key('valueOverrideKey', $overrideKey, $valueOverrides)/value" /> | ||
<xsl:value-of select="$overrideValue" /> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</xsl:element> | ||
</xsl:for-each> | ||
</xsl:template> | ||
</xsl:stylesheet> |
Oops, something went wrong.