-
Notifications
You must be signed in to change notification settings - Fork 0
/
textdiff.xsl
55 lines (45 loc) · 2.06 KB
/
textdiff.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!-- ============================================================================
# < diff.xsl />
# This code implements the diffing algo which I described on my blog
# http://mandarine.tv/#post-117
#
#
#
# Copyright (C) 2011 by Alex Duesel <alex@alex-duesel.de>
# homepage: http://www.mandarine.tv
# See file license.txt for licensing issues
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#============================================================================-->
<xsl:stylesheet version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:textdiff='http://alex-duesel.de/textdiff'
xsl:exclude-result-prefixes='textdiff'>
<!-- textdiff on PCDATA only elements using python xslt transformation libxslt -->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<!-- process only PCDATA elements which are marked as old -->
<xsl:template match="*[@diffing-version='old']">
<xsl:variable name="old" select="."/>
<xsl:variable name="new" select="following-sibling::*"/>
<xsl:copy>
<xsl:apply-templates select="@*"/>
<!-- call textdiff extension function which is declared in diff.py -->
<xsl:value-of select='textdiff:textdiff(string($old),string($new))' disable-output-escaping='yes'/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[@diffing-version='new']"/>
</xsl:stylesheet>