comparison xslt/model.xsl @ 8:5fe2e5724331

sync
author cin
date Wed, 07 Mar 2018 15:54:22 +0300
parents 3fe157be5141
children d3542662cf70
comparison
equal deleted inserted replaced
7:3fe157be5141 8:5fe2e5724331
166 <xsl:with-param name="scope" select="'keys'"/> 166 <xsl:with-param name="scope" select="'keys'"/>
167 </xsl:call-template> 167 </xsl:call-template>
168 </xsl:template> 168 </xsl:template>
169 169
170 <!-- expand-member templates are used to process relations 170 <!-- expand-member templates are used to process relations
171 and keys and provide usefull information like properties of 171 and keys and provide usefull information. This mode is designed
172 the entity which are members of this relation or key. 172 to recursively traverse members expanding details like special
173 properties generated by relations.
174
175 expand-member-reference is special mode used to traverse inside
176 members which are referenced from relations. By default this mode
177 does nothing.
178
179 Use this templates to produce intermediate model for further
180 processing by specific code-generators.
173 181
174 @special - means that the member is a composite part and isn't 182 @special - means that the member is a composite part and isn't
175 accessible directly 183 accessible directly
176 --> 184 -->
177 185
186 <xsl:template match="*" mode="expand-member">
187 <xsl:apply-templates mode="expand-member"/>
188 </xsl:template>
189 <xsl:template match="text()" mode="expand-member"/>
190
191 <xsl:template match="*|text()" mode="expand-member-reference"/>
192
178 <!-- short form of primaryKey{@name, @type} --> 193 <!-- short form of primaryKey{@name, @type} -->
179 <xsl:template match="m:primaryKey" mode="expand-member"> 194 <xsl:template match="m:primaryKey" mode="expand-member">
180 <xsl:copy> 195 <xsl:variable name="specialProperty">
181 <xsl:copy-of select="@*"/>
182 <m:property special="true"> 196 <m:property special="true">
183 <xsl:copy-of select="@*" /> 197 <xsl:copy-of select="@*" />
198 <m:hiddenBy name="{@name}" type="{@declaringType}"/>
184 <xsl:copy-of select="*" /> 199 <xsl:copy-of select="*" />
185 </m:property> 200 </m:property>
186 </xsl:copy> 201 </xsl:variable>
202 <xsl:apply-templates select="exsl:node-set($specialProperty)" mode="expand-member"/>
203 <xsl:apply-templates mode="expand-member"/>
187 </xsl:template> 204 </xsl:template>
188 205
189 <!-- long form of primaryKey{ member{@name}+, property{@name, @type} } --> 206 <!-- long form of primaryKey{ member{@name}+, property{@name, @type} } -->
190 <xsl:template match="m:primaryKey[m:member | m:property]" mode="expand-member"> 207 <xsl:template match="m:primaryKey[m:member | m:property]" mode="expand-member">
191 <xsl:copy> 208 <xsl:apply-templates mode="expand-member"/>
192 <xsl:copy-of select="@*"/>
193 <xsl:apply-templates mode="expand-member"/>
194 </xsl:copy>
195 </xsl:template>
196
197 <!-- stand alone properties -->
198 <xsl:template match="m:property" mode="expand-member">
199 <xsl:copy-of select="."/>
200 </xsl:template> 209 </xsl:template>
201 210
202 <!-- properties declared inside relations, they are @special --> 211 <!-- properties declared inside relations, they are @special -->
203 <xsl:template match="m:primaryKey/m:property | m:thisKey/m:property" mode="expand-member"> 212 <xsl:template match="m:primaryKey/m:property | m:thisKey/m:property" mode="expand-member">
204 <xsl:copy> 213 <xsl:variable name="specialProperty">
205 <xsl:attribute name="special">true</xsl:attribute> 214 <xsl:copy>
206 <xsl:copy-of select="@*"/> 215 <xsl:attribute name="special">true</xsl:attribute>
207 <xsl:copy-of select="*"/> 216 <xsl:copy-of select="@*"/>
208 </xsl:copy> 217 <m:hiddenBy name="{@name}" type="{@declaringType}"/>
209 </xsl:template> 218 <xsl:copy-of select="*"/>
210 219 </xsl:copy>
220 </xsl:variable>
221 <xsl:apply-templates select="exsl:node-set($specialProperty)" mode="expand-member"/>
222 </xsl:template>
223
224 <!-- traverse inside referenced members -->
211 <xsl:template match="m:member" mode="expand-member"> 225 <xsl:template match="m:member" mode="expand-member">
212 <xsl:param name="declaringType"/> 226 <xsl:param name="declaringType"/>
213 <xsl:variable name="expanded"> 227 <xsl:variable name="expanded">
214 <xsl:call-template name="getMembers"> 228 <xsl:call-template name="getMembers">
215 <xsl:with-param name="memberName" select="@name"/> 229 <xsl:with-param name="memberName" select="@name"/>
216 <xsl:with-param name="type" select="$declaringType"/> 230 <xsl:with-param name="type" select="$declaringType"/>
217 </xsl:call-template> 231 </xsl:call-template>
218 </xsl:variable> 232 </xsl:variable>
219 <!-- recusive expand --> 233 <!-- recusive expand -->
220 <xsl:apply-templates select="exsl:node-set($expanded)" mode="expand-member"/> 234 <xsl:apply-templates select="exsl:node-set($expanded)" mode="expand-member-reference"/>
221 </xsl:template> 235 </xsl:template>
222 236
223 <xsl:template match="m:hasA" mode="expand-member"> 237 <xsl:template match="m:hasA/m:thisKey" mode="expand-member">
224 <xsl:copy>
225 <xsl:copy-of select="@*"/>
226
227 <xsl:apply-templates mode="expand-member"/>
228 </xsl:copy>
229 </xsl:template>
230
231 <xsl:template match="m:thisKey" mode="expand-member">
232 <xsl:variable name="otherKey"> 238 <xsl:variable name="otherKey">
233 <xsl:call-template name="getPrimaryKey"> 239 <xsl:call-template name="getPrimaryKey">
234 <xsl:with-param name="type" select="../@type"/> 240 <xsl:with-param name="type" select="../@type"/>
235 </xsl:call-template> 241 </xsl:call-template>
236 </xsl:variable> 242 </xsl:variable>