Remove duplicates from ‘Notes’ section in XHTML rendered XEPs

Test-Information:

Tested on a single XEP that it works as expected. Repeated
notes get the same note number and the notes section only
mentions each note once.
This commit is contained in:
Tobias Markmann 2017-01-11 11:42:16 +01:00 committed by Sam Whited
parent 92d9bbc899
commit de06827d21
1 changed files with 21 additions and 21 deletions

42
xep.xsl
View File

@ -2,7 +2,7 @@
<!-- <!--
Copyright (c) 1999 - 2015 XMPP Standards Foundation Copyright (c) 1999 - 2017 XMPP Standards Foundation
Permission is hereby granted, free of charge, to any Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and person obtaining a copy of this software and
@ -396,9 +396,21 @@ OR OTHER DEALINGS IN THE SOFTWARE.
<!-- NOTES --> <!-- NOTES -->
<a name="appendix-notes"></a> <a name="appendix-notes"></a>
<h3>Appendix G: Notes</h3> <h3>Appendix G: Notes</h3>
<div class='indent'> <div class='indent'>
<xsl:apply-templates select='//note' mode='endlist'/> <xsl:for-each select="//note">
</div> <xsl:variable name='me' select='.' />
<xsl:variable name='firstOccurrence' select='(//note[. = $me])[1]' />
<xsl:variable name='oid' select='generate-id($firstOccurrence)' />
<xsl:variable name='notenum' select='count($firstOccurrence/preceding::note[not(.=preceding::note)])+1' />
<xsl:if test='generate-id($me) = generate-id($firstOccurrence)'>
<p>
<a name='nt-{$oid}'><xsl:value-of select='$notenum'/></a>
<xsl:text>. </xsl:text>
<xsl:apply-templates/>
</p>
</xsl:if>
</xsl:for-each>
</div>
<!-- REVISION HISTORY --> <!-- REVISION HISTORY -->
<hr /> <hr />
<a name="appendix-revs"></a> <a name="appendix-revs"></a>
@ -977,29 +989,17 @@ OR OTHER DEALINGS IN THE SOFTWARE.
</dd> </dd>
</xsl:template> </xsl:template>
<xsl:template match='note'> <xsl:template match='note'>
<xsl:variable name='notenum'> <xsl:variable name='me' select='.' />
<xsl:number level='any' count='note'/> <xsl:variable name='firstOccurrence' select='(//note[. = $me])[1]' />
</xsl:variable> <xsl:variable name='oid' select='generate-id($firstOccurrence)' />
<xsl:variable name='oid'> <xsl:variable name='notenum' select='count($firstOccurrence/preceding::note[not(.=preceding::note)])+1' />
<xsl:call-template name='object.id'/>
</xsl:variable>
<xsl:text> [</xsl:text><a href='#nt-{$oid}'> <xsl:text> [</xsl:text><a href='#nt-{$oid}'>
<xsl:value-of select='$notenum'/></a> <xsl:value-of select='$notenum'/></a>
<xsl:text>]</xsl:text> <xsl:text>]</xsl:text>
</xsl:template> </xsl:template>
<xsl:template match='note' mode='endlist'>
<p>
<xsl:variable name='oid'>
<xsl:call-template name='object.id'/>
</xsl:variable>
<a name='nt-{$oid}'><xsl:value-of select='position()'/></a>
<xsl:text>. </xsl:text>
<xsl:apply-templates/>
</p>
</xsl:template>
<!-- PRESENTATIONAL ELEMENTS --> <!-- PRESENTATIONAL ELEMENTS -->
<xsl:template match='blockquote'> <xsl:template match='blockquote'>