Skip to content

Commit

Permalink
Editor / Fix attribute editing when using a template mode field.
Browse files Browse the repository at this point in the history
If the attribute was present in both the template snippet and
the matching node, then the template was only containing the one
from the node (and the attribute value was not editable).
  • Loading branch information
fxprunayre committed Sep 22, 2016
1 parent 2f56642 commit f9d31b9
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions web/src/main/webapp/xslt/common/utility-tpl-metadata.xsl
Expand Up @@ -75,10 +75,22 @@

<xsl:variable name="nodeName" select="name(.)"/>
<xsl:variable name="parentName" select="name(..)"/>
<xsl:variable name="attrs" select="@*"/>

<xsl:copy>
<xsl:copy-of
select="@*|$node-to-merge/descendant-or-self::node()[name() = $nodeName and name(..) = $parentName]/@*"/>
<!-- Copy all attribute from the template mode first
and then all existing attributes of the equivalent node
which are not defined in the template (to avoid to override
the template attribute by the matching node ones). -->
<xsl:copy-of select="$attrs"/>
<xsl:for-each select="$node-to-merge/descendant-or-self::node()[
name() = $nodeName and name(..) = $parentName
]/@*">
<xsl:variable name="attrName" select="name()"/>
<xsl:if test="count($attrs[name() = $attrName]) = 0">
<xsl:copy-of select="."/>
</xsl:if>
</xsl:for-each>
<xsl:apply-templates mode="gn-merge" select="*">
<xsl:with-param name="node-to-merge" select="$node-to-merge"/>
</xsl:apply-templates>
Expand Down

0 comments on commit f9d31b9

Please sign in to comment.