comparison generator/merge.xsl @ 1:e78566595089

initial import
author mandel
date Mon, 11 May 2009 16:01:50 +0000
parents
children
comparison
equal deleted inserted replaced
0:36fb74dc547d 1:e78566595089
1 <?xml version="1.0"?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 version="1.0">
4 <xsl:output method="xml" indent="yes"/>
5 <xsl:param name="lang" />
6 <xsl:param name="source" />
7
8 <xsl:template match="processing-instruction()" />
9
10 <xsl:template match="/typesystem">
11 <xsl:copy>
12 <xsl:for-each select="@*">
13 <xsl:copy>
14 <xsl:value-of select="." />
15 </xsl:copy>
16 </xsl:for-each>
17
18 <xsl:for-each select="document($source)/typesystem/@*">
19 <xsl:copy>
20 <xsl:value-of select="." />
21 </xsl:copy>
22 </xsl:for-each>
23
24 <xsl:variable name="other" select="document($source)/typesystem/*[not(self::object-type | self::value-type | self::interface-type | self::namespace-type)]" />
25 <xsl:if test="$other">
26 <xsl:choose>
27 <xsl:when test="$lang != ''">
28 <xsl:element name="language">
29 <xsl:attribute name="name" ><xsl:value-of select="$lang" /></xsl:attribute>
30 <xsl:copy-of select="$other" />
31 </xsl:element>
32 </xsl:when>
33 <xsl:otherwise>
34 <xsl:copy-of select="$other" />
35 </xsl:otherwise>
36 </xsl:choose>
37 </xsl:if>
38
39 <xsl:apply-templates select="node()" />
40
41 </xsl:copy>
42 </xsl:template>
43
44
45
46 <xsl:template match="/typesystem/*[self::object-type | self::value-type | self::interface-type | self::namespace-type]">
47 <xsl:variable name="name" select="name()" />
48 <xsl:variable name="other" select="document($source)/typesystem/*[name() = $name][@name = current()/@name]" />
49 <xsl:copy>
50 <xsl:for-each select="@*">
51 <xsl:copy>
52 <xsl:value-of select="." />
53 </xsl:copy>
54 </xsl:for-each>
55 <xsl:for-each select="$other/@*">
56 <xsl:copy>
57 <xsl:value-of select="." />
58 </xsl:copy>
59 </xsl:for-each>
60
61 <xsl:apply-templates select="node()" />
62 <xsl:if test="$other">
63 <xsl:choose>
64 <xsl:when test="$lang != ''">
65 <xsl:element name="language">
66 <xsl:attribute name="name" ><xsl:value-of select="$lang" /></xsl:attribute>
67 <xsl:copy-of select="$other/node()" />
68 </xsl:element>
69 </xsl:when>
70 <xsl:otherwise>
71 <xsl:copy-of select="$other/node()" />
72 </xsl:otherwise>
73 </xsl:choose>
74 </xsl:if>
75 </xsl:copy>
76 </xsl:template>
77
78 <!-- Plain identity transform. -->
79 <xsl:template match="@*|node()">
80 <xsl:copy>
81 <xsl:apply-templates select="@*"/>
82 <xsl:apply-templates select="node()"/>
83 </xsl:copy>
84 </xsl:template>
85
86 </xsl:stylesheet>