<xsl:template match="
div[ (@class=’newtheorem’)
and
child::*[1] / child::span[ @class = ’theorem-head’ ]
]
" >
<xsl:copy>
<xsl:apply-templates select="*|@*|text()|comment()" />
<div class="begin-end" title="speech-extra">
<xsl:value-of select="
concat( ’ end ’,
string( child::*[1] /
child::span[ @class = ’theorem-head’ ] )
) " />
</div>
</xsl:copy>
</xsl:template>
-_-_-