Skip to content

Commit

Permalink
Editor / Conditional helpers are not picked up properly if more than …
Browse files Browse the repository at this point in the history
…2 choices #988.
  • Loading branch information
François Prunayre committed May 11, 2015
1 parent fd6ee4f commit 3193986
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions web/src/main/webapp/xslt/common/functions-metadata.xsl
Expand Up @@ -201,31 +201,36 @@
<!-- Search for the related element identifier -->
<xsl:variable name="relatedElementRef"
select="$node/../*[name()=$helper/@rel]/*/gn:element/@ref"/>



<helper>
<xsl:attribute name="relElementRef" select="$relatedElementRef"/>
<xsl:copy-of select="$helper/@*"/>
<xsl:for-each select="$helper[@displayIf]">
<xsl:variable name="match">
<saxon:call-template name="{concat('evaluate-', $schema)}">
<xsl:with-param name="base" select="$metadata/descendant-or-self::node()[gn:element/@ref = $node/gn:element/@ref]"/>
<xsl:with-param name="in" select="concat('/', @displayIf)"/>
</saxon:call-template>
</xsl:variable>

<xsl:choose>
<xsl:when test="$match/*">
<xsl:variable name="helpersMatchingCurrentRecord">
<xsl:for-each select="$helper[@displayIf]">
<xsl:variable name="match">
<saxon:call-template name="{concat('evaluate-', $schema)}">
<xsl:with-param name="base" select="$metadata/descendant-or-self::node()[gn:element/@ref = $node/gn:element/@ref]"/>
<xsl:with-param name="in" select="concat('/', @displayIf)"/>
</saxon:call-template>
</xsl:variable>

<xsl:if test="$match/*">
<xsl:copy-of select="option"/>
</xsl:when>
<xsl:when test="$helper[not(@displayIf)]">
<!-- The defautl helper is the one with no condition. -->
<xsl:copy-of select="$helper[not(@displayIf)]/*"/>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</xsl:variable>

<xsl:choose>
<xsl:when
test="count($helpersMatchingCurrentRecord) > 0">
<xsl:copy-of select="$helpersMatchingCurrentRecord"/>
</xsl:when>
<xsl:otherwise>
<!-- The default helper is the one with no condition. -->
<xsl:copy-of select="$helper[not(@displayIf)]/*"/>
</xsl:otherwise>
</xsl:choose>
</helper>
</xsl:when>

Expand Down Expand Up @@ -349,7 +354,6 @@
<xsl:param name="node" as="node()"/>
<xsl:variable name="nodePosition" select="$node/position()" />
<xsl:variable name="allPrecedingSiblings" select="$node/preceding-sibling::*[name() = name($node)]" />
<xsl:message select="concat('-------------##$$%% ', $node/name(), ' -- ', count($node/preceding-sibling::*), ' -----------------------------------')" />
<!--<xsl:value-of select="count($node/../*[name = name($node) and position() &lt; $nodePosition]) + 1"/>-->
<xsl:value-of select="count($allPrecedingSiblings) + 1"/>
</xsl:function>
Expand Down

0 comments on commit 3193986

Please sign in to comment.