annotate xslt/model.xsl @ 10:19a8a71eaa54

added test-model.xsl template for testing purpose of model.xsl working on members expansion templates
author cin
date Mon, 12 Mar 2018 02:58:34 +0300
parents d3542662cf70
children
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:t="http://implab.org/schemas/temp" xmlns:exsl="http://exslt.org/common"
10
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
5 exclude-result-prefixes="m xsl exsl">
2
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
6
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
7 <xsl:import href="preprocess.xsl" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
8 <xsl:include href="text-tools.xsl"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
9
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
10 <xsl:output method="xml" indent="yes" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
11
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
12 <xsl:key name="type" match="m:package/m:*" use="@name" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
13
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
14 <xsl:template match="/">
10
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
15 <xsl:apply-templates select="$module" mode="document" />
2
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
16 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
17
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
18 <!-- code generation -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
19
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
20 <!-- disable default template -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
21 <xsl:template match="*|text()" mode="document" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
22
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
23 <xsl:template match="t:module" mode="document">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
24 <xsl:apply-templates mode="document" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
25 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
26
3
437127ab6a12 non-working version
cin
parents: 2
diff changeset
27
2
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
28
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
29 <!-- member resolution traits -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
30
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
31 <!-- Resolves members using given criteria
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
32 @param type
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
33 the name of the type whose members are inspected
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
34 @param memberName
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
35 the name of the member to lookup
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
36 @param scope
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
37 the scope where to look (members, properties, keys, relations)
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
38
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
39 This template recursively inspects the given type down to it's inheritance
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
40 hierarchy and outputs members matching criteria.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
41 -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
42 <xsl:template name="getMembers">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
43 <xsl:param name="type"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
44 <xsl:param name="memberName" select="''"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
45 <xsl:param name="scope" select="'members'"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
46 <!-- prevents cyclic references -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
47 <xsl:param name="seen" select="/.."/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
48 <xsl:for-each select="$module">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
49 <xsl:apply-templates select="key('type', $type)"
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
50 mode="lookup-members">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
51 <xsl:with-param name="memberName" select="$memberName"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
52 <xsl:with-param name="scope" select="$scope"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
53 <xsl:with-param name="seen" select="$seen"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
54 </xsl:apply-templates>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
55 </xsl:for-each>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
56 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
57
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
58 <xsl:template match="*" mode="lookup-members"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
59
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
60 <xsl:template match="m:entity" mode="lookup-members">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
61 <xsl:param name="memberName" select="''"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
62 <xsl:param name="scope" select="'members'"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
63 <xsl:param name="seen"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
64
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
65 <xsl:variable name="self" select="."/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
66
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
67 <xsl:if test="not($seen[generate-id() = generate-id($self)])">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
68 <xsl:variable name="scopeMembers">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
69 <xsl:call-template name="selectScopeMembers">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
70 <xsl:with-param name="scope" select="$scope"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
71 </xsl:call-template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
72 </xsl:variable>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
73
6
1f4009d4afb6 working on model to csharp transform
cin
parents: 4
diff changeset
74 <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
75
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
76 <xsl:choose>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
77 <xsl:when test="$members">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
78 <xsl:copy-of select="$members"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
79 </xsl:when>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
80 <xsl:when test="m:extends">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
81 <xsl:call-template name="getMembers">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
82 <xsl:with-param name="type" select="m:extends/@type"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
83 <xsl:with-param name="memberName" select="$memberName"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
84 <xsl:with-param name="scope" select="$scope"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
85 <xsl:with-param name="seen" select="$seen | $self"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
86 </xsl:call-template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
87 </xsl:when>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
88 <xsl:otherwise>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
89 <xsl:call-template name="warn">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
90 <xsl:with-param name="msg">
6
1f4009d4afb6 working on model to csharp transform
cin
parents: 4
diff changeset
91 <t:trace msg="failed to resolve {$memberName}, scope={$scope}"/>
2
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
92 <t:trace msg="inspected classes">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
93 <xsl:for-each select="$seen | $self">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
94 <t:trace msg="{name()} {@name}"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
95 </xsl:for-each>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
96 </t:trace>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
97 </xsl:with-param>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
98 </xsl:call-template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
99 </xsl:otherwise>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
100 </xsl:choose>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
101 </xsl:if>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
102 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
103
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
104 <!-- this template implements scope filtering -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
105 <xsl:template name="selectScopeMembers">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
106 <xsl:param name="scope" select="'members'"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
107 <xsl:choose>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
108 <xsl:when test="$scope='members'">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
109 <xsl:apply-templates mode="filter-members"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
110 </xsl:when>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
111 <xsl:when test="$scope='keys'">
6
1f4009d4afb6 working on model to csharp transform
cin
parents: 4
diff changeset
112 <xsl:apply-templates mode="filter-keys"/>
2
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
113 </xsl:when>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
114 <xsl:when test="$scope='properties'">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
115 <xsl:apply-templates mode="fiflter-properties"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
116 </xsl:when>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
117 <xsl:when test="$scope='relations'">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
118 <xsl:apply-templates mode="fiflter-relations"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
119 </xsl:when>
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:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
122
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
123 <!-- filter-members -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
124 <xsl:template match="*|text()" mode="filter-members"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
125 <xsl:template match="*[@name]" mode="filter-members">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
126 <xsl:copy>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
127 <xsl:copy-of select="@*" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
128 <xsl:attribute name="declaringType"><xsl:value-of select="../@name" /></xsl:attribute>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
129 <xsl:copy-of select="*" />
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:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
132
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
133 <!-- filter-keys -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
134 <xsl:template match="*|text()" mode="filter-keys"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
135 <xsl:template match="m:primaryKey" mode="filter-keys">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
136 <xsl:apply-templates select="." mode="filter-members"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
137 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
138
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
139 <!-- filter-properties -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
140 <xsl:template match="*|text()" mode="filter-properties"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
141 <xsl:template match="m:property" mode="filter-properties">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
142 <xsl:apply-templates select="." mode="filter-members"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
143 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
144
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
145 <!-- filter-relations -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
146 <xsl:template match="*|text()" mode="filter-relations"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
147 <xsl:template match="m:hasA | m:hasMany" mode="filter-relations">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
148 <xsl:apply-templates select="." mode="filter-members"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
149 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
150
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
151
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
152
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
153 <!-- Resolves primaryKey information for the given type name.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
154 @returns m:primaryKey node copy with additional attribute
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
155 @declaringType which points to the type where this primaryKey
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
156 was defined.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
157 -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
158 <xsl:template name="getPrimaryKey">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
159 <xsl:param name="type" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
160 <xsl:call-template name="getMembers">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
161 <xsl:with-param name="type" select="$type"/>
6
1f4009d4afb6 working on model to csharp transform
cin
parents: 4
diff changeset
162 <xsl:with-param name="scope" select="'keys'"/>
2
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
163 </xsl:call-template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
164 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
165
7
cin
parents: 6
diff changeset
166 <!-- expand-member templates are used to process relations
9
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
167 and keys and provide useful information. This mode is designed
8
cin
parents: 7
diff changeset
168 to recursively traverse members expanding details like special
cin
parents: 7
diff changeset
169 properties generated by relations.
cin
parents: 7
diff changeset
170
cin
parents: 7
diff changeset
171 expand-member-reference is special mode used to traverse inside
cin
parents: 7
diff changeset
172 members which are referenced from relations. By default this mode
10
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
173 creates deep copy of all elements.
8
cin
parents: 7
diff changeset
174
cin
parents: 7
diff changeset
175 Use this templates to produce intermediate model for further
cin
parents: 7
diff changeset
176 processing by specific code-generators.
7
cin
parents: 6
diff changeset
177
cin
parents: 6
diff changeset
178 @special - means that the member is a composite part and isn't
cin
parents: 6
diff changeset
179 accessible directly
cin
parents: 6
diff changeset
180 -->
cin
parents: 6
diff changeset
181
8
cin
parents: 7
diff changeset
182 <xsl:template match="*" mode="expand-member">
9
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
183 <xsl:copy>
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
184 <xsl:copy-of select="@*"/>
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
185 <xsl:apply-templates mode="expand-member"/>
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
186 </xsl:copy>
8
cin
parents: 7
diff changeset
187 </xsl:template>
cin
parents: 7
diff changeset
188
cin
parents: 7
diff changeset
189
7
cin
parents: 6
diff changeset
190 <!-- short form of primaryKey{@name, @type} -->
10
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
191 <xsl:template match="m:primaryKey[not(m:member)]" mode="expand-member">
9
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
192 <xsl:variable name="pkName" select="concat(@declaringType, 'Pk')"/>
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
193 <xsl:variable name="propName" select="@name" />
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
194
8
cin
parents: 7
diff changeset
195 <xsl:variable name="specialProperty">
9
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
196 <m:property name="{$propName}" special="true">
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
197 <xsl:copy-of select="@*[not(self::name)]" />
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
198 <m:hiddenBy name="{$pkName}" 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>
9
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
202
8
cin
parents: 7
diff changeset
203 <xsl:apply-templates select="exsl:node-set($specialProperty)" mode="expand-member"/>
9
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
204 <xsl:copy>
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
205 <xsl:attribute name="name"><xsl:value-of select="$pkName"/></xsl:attribute>
10
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
206 <xsl:attribute name="declarigType"><xsl:value-of select="@declaringType"/></xsl:attribute>
9
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
207 <m:member name="{@name}" type="{@declaringType}"/>
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
208 </xsl:copy>
7
cin
parents: 6
diff changeset
209 </xsl:template>
cin
parents: 6
diff changeset
210
9
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
211 <!-- long form of primaryKey{ member{@name}+ } -->
10
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
212 <!-- will be processed using default template -->
7
cin
parents: 6
diff changeset
213
9
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
214 <!-- short form of hasA -->
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
215 <xsl:template match="m:hasA" mode="expand-member">
10
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
216 <xsl:variable name="thisPrefix" select="@name"/>
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
217
9
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
218 <xsl:variable name="foreignPk">
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
219 <xsl:call-template name="getPrimaryKey">
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
220 <xsl:with-param name="type" select="@type"/>
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
221 </xsl:call-template>
8
cin
parents: 7
diff changeset
222 </xsl:variable>
9
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
223 <xsl:variable name="expandedPk">
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
224 <xsl:apply-templates select="exsl:node-set($foreignPk)" mode="expand-member"/>
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
225 </xsl:variable>
10
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
226 <xsl:variable name="pkMembers">
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
227 <xsl:apply-templates select="exsl:node-set($expandedPk)/*[not(@special)]" mode="resolve-members"/>
9
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
228 </xsl:variable>
10
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
229 <t:fk>
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
230 <xsl:for-each select="exsl:node-set($pkMembers)/*">
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
231 <t:thisKey name="{$thisPrefix}{@name}" matches="{@name}">
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
232 <xsl:copy-of select="."/>
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
233 </t:thisKey>
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
234 </xsl:for-each>
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
235 </t:fk>
7
cin
parents: 6
diff changeset
236 </xsl:template>
cin
parents: 6
diff changeset
237
9
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
238 <!-- short form of hasA with matched keys specified -->
10
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
239 <!-- TODO -->
9
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
240 <xsl:template match="m:hasA[m:thisKey]">
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
241 <xsl:apply-templates select="m:thisKey" mode="generate-fk-properties"/>
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
242 <xsl:copy>
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
243 <xsl:copy-of select="@*"/>
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
244 <xsl:apply-templates mode="expand-member"/>
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
245 </xsl:copy>
7
cin
parents: 6
diff changeset
246 </xsl:template>
cin
parents: 6
diff changeset
247
8
cin
parents: 7
diff changeset
248 <xsl:template match="m:hasA/m:thisKey" mode="expand-member">
10
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
249 <m:member name="{@name}" matches="{@matches}" type="{../@declaringType}"/>
7
cin
parents: 6
diff changeset
250 </xsl:template>
cin
parents: 6
diff changeset
251
9
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
252 <!-- long form of hasA -->
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
253 <xsl:template match="m:hasA[m:member]" mode="expand-member">
7
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
10
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
257 <!-- resolve-members -->
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
258 <!-- processes members and copies members to output -->
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
259 <!-- TODO: Possible recursion -->
9
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
260 <xsl:template match="m:member" mode="resolve-members">
10
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
261 <xsl:variable name="name" select="@name"/>
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
262 <xsl:variable name="declaringType" select="@type" />
9
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
263 <xsl:choose>
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
264 <xsl:when test="/*[@name=$name and @declaringType=$declaringType]">
10
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
265 <!-- when reference points to a locally defined member -->
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
266 <!-- locally defined members are already expanded -->
9
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
267 <xsl:apply-templates select="/*[@name=$name and @declaringType=$declaringType]" mode="resolve-members"/>
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
268 </xsl:when>
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
269 <xsl:otherwise>
10
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
270 <!-- otherwise try to use getMembers, then expand it and resolve members -->
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
271 <xsl:variable name="members">
9
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
272 <xsl:call-template name="getMembers">
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
273 <xsl:with-param name="memberName" select="$name"/>
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
274 <xsl:with-param name="type" select="$declaringType"/>
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
275 </xsl:call-template>
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
276 </xsl:variable>
10
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
277 <!-- expand resolved members like 'hasA' and 'thisKey' -->
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
278 <xsl:variable name="expanded">
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
279 <xsl:apply-templates select="exsl:node-set($members)" mode="resolve-members"/>
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
280 </xsl:variable>
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
281 <!-- skip @special members when resolving -->
19a8a71eaa54 added test-model.xsl template for testing purpose of model.xsl
cin
parents: 9
diff changeset
282 <xsl:apply-templates select="exsl:node-set($expanded)/*[not(@special)]" mode="resolve-members"/>
9
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
283 </xsl:otherwise>
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
284 </xsl:choose>
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
285 </xsl:template>
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
286
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
287 <xsl:template match="m:property" mode="resolve-members">
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
288 <xsl:copy-of select="."/>
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
289 </xsl:template>
d3542662cf70 working on members preprocessing
cin
parents: 8
diff changeset
290
2
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
291 </xsl:stylesheet>