annotate xslt/model.xsl @ 2:035de8b7b18e

Temporary commit, refactoring, added readme
author cin
date Sun, 25 Feb 2018 17:12:33 +0300
parents
children 437127ab6a12
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
1 <?xml version="1.0" encoding="UTF-8"?>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
2 <xsl:stylesheet version="1.0"
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:m="http://implab.org/schemas/data-model.v1.xsd"
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
4 xmlns:clr="http://implab.org/schemas/data-model/dotnet.v1.xsd"
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
5 xmlns:cs="http://implab.org/schemas/code-dom/csharp.v1.xsd" xmlns:sql="http://implab.org/schemas/data-model/sql.v1.xsd"
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
6 xmlns:t="http://implab.org/schemas/temp" xmlns:exsl="http://exslt.org/common"
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
7 exclude-result-prefixes="clr m xsl exsl sql">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
8
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
9 <xsl:import href="preprocess.xsl" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
10 <xsl:include href="text-tools.xsl"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
11
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
12 <xsl:output method="xml" indent="yes" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
13
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
14 <xsl:key name="type" match="m:package/m:*" use="@name" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
15
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
16 <xsl:template match="/">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
17 <cs:document>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
18 <xsl:apply-templates select="$module" mode="document" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
19 </cs:document>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
20 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
21
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
22 <!-- code generation -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
23
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
24 <!-- disable default template -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
25 <xsl:template match="*|text()" mode="document" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
26
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
27 <xsl:template match="t:module" mode="document">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
28 <xsl:apply-templates mode="document" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
29 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
30
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
31 <!-- generate code for primary package -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
32 <xsl:template match="m:package[@primary='true' and @clr:namespace]" mode="document">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
33 <cs:namespace name="{@clr:namespace}">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
34 <xsl:apply-templates mode="document" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
35 </cs:namespace>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
36 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
37
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
38 <xsl:template match="m:package[@primary='true']" mode="document">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
39 <xsl:apply-templates mode="document" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
40 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
41
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
42 <!-- member resolution traits -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
43
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
44 <!-- Resolves members using given criteria
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
45 @param type
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
46 the name of the type whose members are inspected
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
47 @param memberName
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
48 the name of the member to lookup
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
49 @param scope
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
50 the scope where to look (members, properties, keys, relations)
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
51
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
52 This template recursively inspects the given type down to it's inheritance
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
53 hierarchy and outputs members matching criteria.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
54 -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
55 <xsl:template name="getMembers">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
56 <xsl:param name="type"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
57 <xsl:param name="memberName" select="''"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
58 <xsl:param name="scope" select="'members'"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
59 <!-- prevents cyclic references -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
60 <xsl:param name="seen" select="/.."/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
61 <xsl:for-each select="$module">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
62 <xsl:apply-templates select="key('type', $type)"
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
63 mode="lookup-members">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
64 <xsl:with-param name="memberName" select="$memberName"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
65 <xsl:with-param name="scope" select="$scope"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
66 <xsl:with-param name="seen" select="$seen"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
67 </xsl:apply-templates>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
68 </xsl:for-each>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
69 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
70
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
71 <xsl:template match="*" mode="lookup-members"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
72
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
73 <xsl:template match="m:entity" mode="lookup-members">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
74 <xsl:param name="memberName" select="''"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
75 <xsl:param name="scope" select="'members'"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
76 <xsl:param name="seen"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
77
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
78 <xsl:variable name="self" select="."/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
79
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
80 <xsl:if test="not($seen[generate-id() = generate-id($self)])">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
81 <xsl:variable name="scopeMembers">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
82 <xsl:call-template name="selectScopeMembers">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
83 <xsl:with-param name="scope" select="$scope"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
84 </xsl:call-template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
85 </xsl:variable>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
86
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
87 <xsl:variable name="members" select="exsl:node-set($scopeMembers)/*[not($memberName) or @name='$memberName']"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
88
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
89 <xsl:choose>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
90 <xsl:when test="$members">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
91 <xsl:copy-of select="$members"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
92 </xsl:when>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
93 <xsl:when test="m:extends">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
94 <xsl:call-template name="getMembers">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
95 <xsl:with-param name="type" select="m:extends/@type"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
96 <xsl:with-param name="memberName" select="$memberName"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
97 <xsl:with-param name="scope" select="$scope"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
98 <xsl:with-param name="seen" select="$seen | $self"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
99 </xsl:call-template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
100 </xsl:when>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
101 <xsl:otherwise>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
102 <xsl:call-template name="warn">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
103 <xsl:with-param name="msg">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
104 <t:trace msg="failed to resolve {$member}"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
105 <t:trace msg="inspected classes">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
106 <xsl:for-each select="$seen | $self">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
107 <t:trace msg="{name()} {@name}"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
108 </xsl:for-each>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
109 </t:trace>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
110 </xsl:with-param>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
111 </xsl:call-template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
112 </xsl:otherwise>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
113 </xsl:choose>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
114 </xsl:if>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
115 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
116
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
117 <!-- this template implements scope filtering -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
118 <xsl:template name="selectScopeMembers">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
119 <xsl:param name="scope" select="'members'"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
120 <xsl:choose>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
121 <xsl:when test="$scope='members'">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
122 <xsl:apply-templates mode="filter-members"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
123 </xsl:when>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
124 <xsl:when test="$scope='keys'">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
125 <xsl:apply-template mode="filter-keys"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
126 </xsl:when>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
127 <xsl:when test="$scope='properties'">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
128 <xsl:apply-templates mode="fiflter-properties"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
129 </xsl:when>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
130 <xsl:when test="$scope='relations'">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
131 <xsl:apply-templates mode="fiflter-relations"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
132 </xsl:when>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
133 </xsl:choose>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
134 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
135
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
136 <!-- filter-members -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
137 <xsl:template match="*|text()" mode="filter-members"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
138 <xsl:template match="*[@name]" mode="filter-members">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
139 <xsl:copy>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
140 <xsl:copy-of select="@*" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
141 <xsl:attribute name="declaringType"><xsl:value-of select="../@name" /></xsl:attribute>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
142 <xsl:copy-of select="*" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
143 </xsl:copy>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
144 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
145
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
146 <!-- filter-keys -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
147 <xsl:template match="*|text()" mode="filter-keys"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
148 <xsl:template match="m:primaryKey" mode="filter-keys">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
149 <xsl:apply-templates select="." mode="filter-members"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
150 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
151
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
152 <!-- filter-properties -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
153 <xsl:template match="*|text()" mode="filter-properties"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
154 <xsl:template match="m:property" mode="filter-properties">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
155 <xsl:apply-templates select="." mode="filter-members"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
156 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
157
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
158 <!-- filter-relations -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
159 <xsl:template match="*|text()" mode="filter-relations"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
160 <xsl:template match="m:hasA | m:hasMany" mode="filter-relations">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
161 <xsl:apply-templates select="." mode="filter-members"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
162 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
163
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
164
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
165
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
166 <!-- primary key -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
167
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
168 <!-- Resolves primaryKey information for the given type name.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
169 @returns m:primaryKey node copy with additional attribute
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
170 @declaringType which points to the type where this primaryKey
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
171 was defined.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
172 -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
173 <xsl:template name="getPrimaryKey">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
174 <xsl:param name="type" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
175 <xsl:call-template name="getMembers">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
176 <xsl:with-param name="type" select="$type"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
177 <xsl:with-param name="scope" select="keys"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
178 </xsl:call-template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
179 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
180
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
181 <!-- -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
182 <xsl:template name="getKeyType">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
183 <xsl:param name="type" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
184 <xsl:variable name="otherKey">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
185 <xsl:call-template name="getKey">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
186 <xsl:with-param name="type" select="$type" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
187 </xsl:call-template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
188 </xsl:variable>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
189 <xsl:apply-templates select="exsl:node-set($otherKey)/m:primaryKey" mode="property-type"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
190 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
191
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
192 <xsl:template name="getKeyName">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
193 <xsl:param name="type" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
194 <xsl:variable name="otherKey">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
195 <xsl:call-template name="getKey">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
196 <xsl:with-param name="type" select="$type" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
197 </xsl:call-template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
198 </xsl:variable>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
199 <xsl:apply-templates select="exsl:node-set($otherKey)/m:primaryKey" mode="property-name"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
200 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
201
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
202 <!-- internal. applied to the entity with a primaryKey node -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
203 <xsl:template match="m:entity[m:primaryKey]" mode="resolvePK">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
204 <xsl:apply-templates select="m:primaryKey" mode="resolvePK" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
205 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
206
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
207 <!--
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
208 This template formats the result of 'resolvePk' template,
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
209 override this template to extend returned metadata, beware that
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
210 other templates rely on the resulting format of this template.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
211 -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
212 <xsl:template match="m:primaryKey" mode="resolvePK">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
213 <xsl:copy>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
214 <xsl:copy-of select="@*" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
215 <xsl:attribute name="declaringType"><xsl:value-of select="../@name" /></xsl:attribute>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
216 <xsl:copy-of select="*" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
217 </xsl:copy>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
218 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
219
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
220 <!-- internal, used to traverse the hierarchy -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
221 <xsl:template match="m:entity" mode="resolvePK">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
222 <xsl:apply-templates select="m:extends" mode="resolvePK" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
223 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
224
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
225 <!-- internal, used to traverse the hierarchy -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
226 <xsl:template match="m:extends" mode="resolvePK">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
227 <xsl:apply-templates select="key('type', @type)"
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
228 mode="resolvePK" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
229 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
230
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
231 <!-- resolves CLR type for the given type -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
232 <xsl:template name="getClrType">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
233 <xsl:param name="type" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
234 <xsl:param name="typeArgs" select="/.." />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
235 <!-- <t:trace msg="resolveClrType {$type}"/> -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
236 <xsl:for-each select="$module">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
237 <xsl:apply-templates select="key('type', $type)"
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
238 mode="clr-type">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
239 <xsl:with-param name="typeArgs" select="$typeArgs"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
240 </xsl:apply-templates>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
241 </xsl:for-each>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
242 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
243
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
244 <!-- CLR type construction -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
245 <xsl:template match="*" mode="clr-type" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
246
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
247 <xsl:template match="m:type[clr:type]" mode="clr-type">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
248 <xsl:param name="typeArgs" select="clr:type/*" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
249 <xsl:apply-templates select="clr:type" mode="clr-type">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
250 <xsl:with-param name="typeArgs" select="$typeArgs" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
251 </xsl:apply-templates>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
252 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
253
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
254 <xsl:template match="m:entity" mode="clr-type">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
255 <cs:type name="{@clr:name | @name[not(../@clr:name)]}" namespace="{ancestor::*[@clr:namespace]/@clr:namespace}" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
256 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
257
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
258 <xsl:template match="clr:type" mode="clr-type">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
259 <xsl:apply-templates mode="clr-type"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
260 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
261
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
262 <xsl:template match="clr:type[@ref]" mode="clr-type">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
263 <xsl:param name="typeArgs" select="*" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
264 <xsl:call-template name="getClrType">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
265 <xsl:with-param name="type" select="@ref" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
266 <xsl:with-param name="typeArgs" select="$typeArgs" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
267 </xsl:call-template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
268 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
269
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
270 <xsl:template match="clr:type[@cs:name or @name]" mode="clr-type">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
271 <xsl:param name="typeArgs" select="*" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
272 <xsl:variable name="ns"
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
273 select="@cs:namespace | @namespace[not(../@cs:namespace)]" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
274 <cs:type name="{@cs:name | @name[not(../@cs:name)]}">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
275 <xsl:if test="$ns">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
276 <xsl:attribute name="namespace"><xsl:value-of select="$ns" /></xsl:attribute>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
277 </xsl:if>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
278 <xsl:copy-of select="@struct"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
279
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
280 <xsl:apply-templates select="$typeArgs | *[not($typeArgs)]"
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
281 mode="clr-type" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
282 </cs:type>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
283 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
284
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
285 <xsl:template match="clr:arrayOf[@type]" mode="clr-type">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
286 <xsl:param name="typeArgs" select="*" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
287 <cs:array>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
288 <xsl:call-template name="getClrType">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
289 <xsl:with-param name="type" select="@type" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
290 <xsl:with-param name="typeArgs" select="$typeArgs" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
291 </xsl:call-template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
292 </cs:array>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
293 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
294
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
295 <xsl:template match="clr:arrayOf[@cs:name or @name]" mode="clr-type">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
296 <xsl:param name="typeArgs" select="*" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
297 <xsl:variable name="ns"
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
298 select="@cs:namespace | @namespace[not(../@cs:namespace)]" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
299 <cs:array>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
300 <cs:type name="{@cs:name | @name[not(../@cs:name)]}">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
301 <xsl:if test="$ns">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
302 <xsl:attribute name="namespace"><xsl:value-of
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
303 select="$ns" /></xsl:attribute>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
304 </xsl:if>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
305 <xsl:apply-templates select="$typeArgs | *[not($typeArgs)]"
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
306 mode="clr-type" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
307 </cs:type>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
308 </cs:array>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
309 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
310
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
311
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
312 </xsl:stylesheet>