annotate xslt/model.xsl @ 8:5fe2e5724331

sync
author cin
date Wed, 07 Mar 2018 15:54:22 +0300
parents 3fe157be5141
children d3542662cf70
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
3
437127ab6a12 non-working version
cin
parents: 2
diff changeset
31
2
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
32
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
33 <!-- member resolution traits -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
34
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
35 <!-- Resolves members using given criteria
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
36 @param type
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
37 the name of the type whose members are inspected
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
38 @param memberName
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
39 the name of the member to lookup
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
40 @param scope
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
41 the scope where to look (members, properties, keys, relations)
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
42
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
43 This template recursively inspects the given type down to it's inheritance
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
44 hierarchy and outputs members matching criteria.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
45 -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
46 <xsl:template name="getMembers">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
47 <xsl:param name="type"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
48 <xsl:param name="memberName" select="''"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
49 <xsl:param name="scope" select="'members'"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
50 <!-- prevents cyclic references -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
51 <xsl:param name="seen" select="/.."/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
52 <xsl:for-each select="$module">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
53 <xsl:apply-templates select="key('type', $type)"
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
54 mode="lookup-members">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
55 <xsl:with-param name="memberName" select="$memberName"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
56 <xsl:with-param name="scope" select="$scope"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
57 <xsl:with-param name="seen" select="$seen"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
58 </xsl:apply-templates>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
59 </xsl:for-each>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
60 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
61
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
62 <xsl:template match="*" mode="lookup-members"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
63
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
64 <xsl:template match="m:entity" mode="lookup-members">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
65 <xsl:param name="memberName" select="''"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
66 <xsl:param name="scope" select="'members'"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
67 <xsl:param name="seen"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
68
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
69 <xsl:variable name="self" select="."/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
70
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
71 <xsl:if test="not($seen[generate-id() = generate-id($self)])">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
72 <xsl:variable name="scopeMembers">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
73 <xsl:call-template name="selectScopeMembers">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
74 <xsl:with-param name="scope" select="$scope"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
75 </xsl:call-template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
76 </xsl:variable>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
77
6
1f4009d4afb6 working on model to csharp transform
cin
parents: 4
diff changeset
78 <xsl:variable name="members" select="exsl:node-set($scopeMembers)/*[not($memberName) or @name=$memberName]"/>
2
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
79
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
80 <xsl:choose>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
81 <xsl:when test="$members">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
82 <xsl:copy-of select="$members"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
83 </xsl:when>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
84 <xsl:when test="m:extends">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
85 <xsl:call-template name="getMembers">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
86 <xsl:with-param name="type" select="m:extends/@type"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
87 <xsl:with-param name="memberName" select="$memberName"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
88 <xsl:with-param name="scope" select="$scope"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
89 <xsl:with-param name="seen" select="$seen | $self"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
90 </xsl:call-template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
91 </xsl:when>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
92 <xsl:otherwise>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
93 <xsl:call-template name="warn">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
94 <xsl:with-param name="msg">
6
1f4009d4afb6 working on model to csharp transform
cin
parents: 4
diff changeset
95 <t:trace msg="failed to resolve {$memberName}, scope={$scope}"/>
2
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
96 <t:trace msg="inspected classes">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
97 <xsl:for-each select="$seen | $self">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
98 <t:trace msg="{name()} {@name}"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
99 </xsl:for-each>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
100 </t:trace>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
101 </xsl:with-param>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
102 </xsl:call-template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
103 </xsl:otherwise>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
104 </xsl:choose>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
105 </xsl:if>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
106 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
107
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
108 <!-- this template implements scope filtering -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
109 <xsl:template name="selectScopeMembers">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
110 <xsl:param name="scope" select="'members'"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
111 <xsl:choose>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
112 <xsl:when test="$scope='members'">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
113 <xsl:apply-templates mode="filter-members"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
114 </xsl:when>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
115 <xsl:when test="$scope='keys'">
6
1f4009d4afb6 working on model to csharp transform
cin
parents: 4
diff changeset
116 <xsl:apply-templates mode="filter-keys"/>
2
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
117 </xsl:when>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
118 <xsl:when test="$scope='properties'">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
119 <xsl:apply-templates mode="fiflter-properties"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
120 </xsl:when>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
121 <xsl:when test="$scope='relations'">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
122 <xsl:apply-templates mode="fiflter-relations"/>
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:choose>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
125 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
126
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
127 <!-- filter-members -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
128 <xsl:template match="*|text()" mode="filter-members"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
129 <xsl:template match="*[@name]" mode="filter-members">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
130 <xsl:copy>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
131 <xsl:copy-of select="@*" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
132 <xsl:attribute name="declaringType"><xsl:value-of select="../@name" /></xsl:attribute>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
133 <xsl:copy-of select="*" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
134 </xsl:copy>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
135 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
136
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
137 <!-- filter-keys -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
138 <xsl:template match="*|text()" mode="filter-keys"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
139 <xsl:template match="m:primaryKey" mode="filter-keys">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
140 <xsl:apply-templates select="." mode="filter-members"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
141 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
142
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
143 <!-- filter-properties -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
144 <xsl:template match="*|text()" mode="filter-properties"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
145 <xsl:template match="m:property" mode="filter-properties">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
146 <xsl:apply-templates select="." mode="filter-members"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
147 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
148
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
149 <!-- filter-relations -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
150 <xsl:template match="*|text()" mode="filter-relations"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
151 <xsl:template match="m:hasA | m:hasMany" mode="filter-relations">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
152 <xsl:apply-templates select="." mode="filter-members"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
153 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
154
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
155
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
156
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
157 <!-- Resolves primaryKey information for the given type name.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
158 @returns m:primaryKey node copy with additional attribute
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
159 @declaringType which points to the type where this primaryKey
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
160 was defined.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
161 -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
162 <xsl:template name="getPrimaryKey">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
163 <xsl:param name="type" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
164 <xsl:call-template name="getMembers">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
165 <xsl:with-param name="type" select="$type"/>
6
1f4009d4afb6 working on model to csharp transform
cin
parents: 4
diff changeset
166 <xsl:with-param name="scope" select="'keys'"/>
2
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
167 </xsl:call-template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
168 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
169
7
cin
parents: 6
diff changeset
170 <!-- expand-member templates are used to process relations
8
cin
parents: 7
diff changeset
171 and keys and provide usefull information. This mode is designed
cin
parents: 7
diff changeset
172 to recursively traverse members expanding details like special
cin
parents: 7
diff changeset
173 properties generated by relations.
cin
parents: 7
diff changeset
174
cin
parents: 7
diff changeset
175 expand-member-reference is special mode used to traverse inside
cin
parents: 7
diff changeset
176 members which are referenced from relations. By default this mode
cin
parents: 7
diff changeset
177 does nothing.
cin
parents: 7
diff changeset
178
cin
parents: 7
diff changeset
179 Use this templates to produce intermediate model for further
cin
parents: 7
diff changeset
180 processing by specific code-generators.
7
cin
parents: 6
diff changeset
181
cin
parents: 6
diff changeset
182 @special - means that the member is a composite part and isn't
cin
parents: 6
diff changeset
183 accessible directly
cin
parents: 6
diff changeset
184 -->
cin
parents: 6
diff changeset
185
8
cin
parents: 7
diff changeset
186 <xsl:template match="*" mode="expand-member">
cin
parents: 7
diff changeset
187 <xsl:apply-templates mode="expand-member"/>
cin
parents: 7
diff changeset
188 </xsl:template>
cin
parents: 7
diff changeset
189 <xsl:template match="text()" mode="expand-member"/>
cin
parents: 7
diff changeset
190
cin
parents: 7
diff changeset
191 <xsl:template match="*|text()" mode="expand-member-reference"/>
cin
parents: 7
diff changeset
192
7
cin
parents: 6
diff changeset
193 <!-- short form of primaryKey{@name, @type} -->
cin
parents: 6
diff changeset
194 <xsl:template match="m:primaryKey" mode="expand-member">
8
cin
parents: 7
diff changeset
195 <xsl:variable name="specialProperty">
7
cin
parents: 6
diff changeset
196 <m:property special="true">
cin
parents: 6
diff changeset
197 <xsl:copy-of select="@*" />
8
cin
parents: 7
diff changeset
198 <m:hiddenBy name="{@name}" type="{@declaringType}"/>
7
cin
parents: 6
diff changeset
199 <xsl:copy-of select="*" />
cin
parents: 6
diff changeset
200 </m:property>
8
cin
parents: 7
diff changeset
201 </xsl:variable>
cin
parents: 7
diff changeset
202 <xsl:apply-templates select="exsl:node-set($specialProperty)" mode="expand-member"/>
cin
parents: 7
diff changeset
203 <xsl:apply-templates mode="expand-member"/>
7
cin
parents: 6
diff changeset
204 </xsl:template>
cin
parents: 6
diff changeset
205
cin
parents: 6
diff changeset
206 <!-- long form of primaryKey{ member{@name}+, property{@name, @type} } -->
cin
parents: 6
diff changeset
207 <xsl:template match="m:primaryKey[m:member | m:property]" mode="expand-member">
8
cin
parents: 7
diff changeset
208 <xsl:apply-templates mode="expand-member"/>
7
cin
parents: 6
diff changeset
209 </xsl:template>
cin
parents: 6
diff changeset
210
cin
parents: 6
diff changeset
211 <!-- properties declared inside relations, they are @special -->
cin
parents: 6
diff changeset
212 <xsl:template match="m:primaryKey/m:property | m:thisKey/m:property" mode="expand-member">
8
cin
parents: 7
diff changeset
213 <xsl:variable name="specialProperty">
cin
parents: 7
diff changeset
214 <xsl:copy>
cin
parents: 7
diff changeset
215 <xsl:attribute name="special">true</xsl:attribute>
cin
parents: 7
diff changeset
216 <xsl:copy-of select="@*"/>
cin
parents: 7
diff changeset
217 <m:hiddenBy name="{@name}" type="{@declaringType}"/>
cin
parents: 7
diff changeset
218 <xsl:copy-of select="*"/>
cin
parents: 7
diff changeset
219 </xsl:copy>
cin
parents: 7
diff changeset
220 </xsl:variable>
cin
parents: 7
diff changeset
221 <xsl:apply-templates select="exsl:node-set($specialProperty)" mode="expand-member"/>
7
cin
parents: 6
diff changeset
222 </xsl:template>
cin
parents: 6
diff changeset
223
8
cin
parents: 7
diff changeset
224 <!-- traverse inside referenced members -->
7
cin
parents: 6
diff changeset
225 <xsl:template match="m:member" mode="expand-member">
cin
parents: 6
diff changeset
226 <xsl:param name="declaringType"/>
cin
parents: 6
diff changeset
227 <xsl:variable name="expanded">
cin
parents: 6
diff changeset
228 <xsl:call-template name="getMembers">
cin
parents: 6
diff changeset
229 <xsl:with-param name="memberName" select="@name"/>
cin
parents: 6
diff changeset
230 <xsl:with-param name="type" select="$declaringType"/>
cin
parents: 6
diff changeset
231 </xsl:call-template>
cin
parents: 6
diff changeset
232 </xsl:variable>
cin
parents: 6
diff changeset
233 <!-- recusive expand -->
8
cin
parents: 7
diff changeset
234 <xsl:apply-templates select="exsl:node-set($expanded)" mode="expand-member-reference"/>
7
cin
parents: 6
diff changeset
235 </xsl:template>
cin
parents: 6
diff changeset
236
8
cin
parents: 7
diff changeset
237 <xsl:template match="m:hasA/m:thisKey" mode="expand-member">
7
cin
parents: 6
diff changeset
238 <xsl:variable name="otherKey">
cin
parents: 6
diff changeset
239 <xsl:call-template name="getPrimaryKey">
cin
parents: 6
diff changeset
240 <xsl:with-param name="type" select="../@type"/>
cin
parents: 6
diff changeset
241 </xsl:call-template>
cin
parents: 6
diff changeset
242 </xsl:variable>
cin
parents: 6
diff changeset
243 <xsl:variable name="otherKeyExpanded">
cin
parents: 6
diff changeset
244 <xsl:apply-templates select="exsl:node-set($otherKey)" mode="expand-member"/>
cin
parents: 6
diff changeset
245 </xsl:variable>
cin
parents: 6
diff changeset
246 <xsl:variable name="pk" select="exsl:node-set($otherKeyExpanded)[1]"/>
cin
parents: 6
diff changeset
247
cin
parents: 6
diff changeset
248 <m:property name="{@name}" type="{$pk/@type}" hidden="true">
cin
parents: 6
diff changeset
249 <m:related name="{$pk/@name}" type="{../@type}"/>
cin
parents: 6
diff changeset
250 </m:property>
cin
parents: 6
diff changeset
251 </xsl:template>
cin
parents: 6
diff changeset
252
cin
parents: 6
diff changeset
253 <xsl:template match="m:thisKey[m:member | property]">
cin
parents: 6
diff changeset
254 <xsl:apply-templates mode="expand-member"/>
cin
parents: 6
diff changeset
255 </xsl:template>
cin
parents: 6
diff changeset
256
2
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
257 </xsl:stylesheet>