Skip to content

Commit

Permalink
try to prevent duplicate xml:ids from being generated -- or at least …
Browse files Browse the repository at this point in the history
…make it less likely, relevant to issue #66
  • Loading branch information
EfraimFeinstein committed Mar 20, 2018
1 parent 8322802 commit 79b43fa
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion js/text/AddXmlId.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
<xsl:param name="element-name" as="xs:string?"/>
<!-- add a randomly generated xml:id -->
<xsl:if test="exists($element-name) and not(@id)">
<xsl:attribute name="id" select="concat(substring-after($element-name, '-'), '_', generate-id(.))"/>
<!-- WARNING: generate-id() is implemented to assign an id to a document and an id to a node based on
its position. If a node's position changes, there could be a duplicate id generated.
Therefore, we have to add something dependent on the node's current position -->
<xsl:attribute name="id" select="concat(substring-after($element-name, '-'), '_', generate-id(.),
count(preceding-sibling::*), count(following-sibling::*))"/>
</xsl:if>
</xsl:template>

Expand Down

0 comments on commit 79b43fa

Please sign in to comment.