comparison xslt/model.xsl @ 7:3fe157be5141

sync
author cin
date Tue, 06 Mar 2018 19:27:25 +0300
parents 1f4009d4afb6
children 5fe2e5724331
comparison
equal deleted inserted replaced
6:1f4009d4afb6 7:3fe157be5141
165 <xsl:with-param name="type" select="$type"/> 165 <xsl:with-param name="type" select="$type"/>
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
171 and keys and provide usefull information like properties of
172 the entity which are members of this relation or key.
173
174 @special - means that the member is a composite part and isn't
175 accessible directly
176 -->
177
178 <!-- short form of primaryKey{@name, @type} -->
179 <xsl:template match="m:primaryKey" mode="expand-member">
180 <xsl:copy>
181 <xsl:copy-of select="@*"/>
182 <m:property special="true">
183 <xsl:copy-of select="@*" />
184 <xsl:copy-of select="*" />
185 </m:property>
186 </xsl:copy>
187 </xsl:template>
188
189 <!-- long form of primaryKey{ member{@name}+, property{@name, @type} } -->
190 <xsl:template match="m:primaryKey[m:member | m:property]" mode="expand-member">
191 <xsl:copy>
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>
201
202 <!-- properties declared inside relations, they are @special -->
203 <xsl:template match="m:primaryKey/m:property | m:thisKey/m:property" mode="expand-member">
204 <xsl:copy>
205 <xsl:attribute name="special">true</xsl:attribute>
206 <xsl:copy-of select="@*"/>
207 <xsl:copy-of select="*"/>
208 </xsl:copy>
209 </xsl:template>
210
211 <xsl:template match="m:member" mode="expand-member">
212 <xsl:param name="declaringType"/>
213 <xsl:variable name="expanded">
214 <xsl:call-template name="getMembers">
215 <xsl:with-param name="memberName" select="@name"/>
216 <xsl:with-param name="type" select="$declaringType"/>
217 </xsl:call-template>
218 </xsl:variable>
219 <!-- recusive expand -->
220 <xsl:apply-templates select="exsl:node-set($expanded)" mode="expand-member"/>
221 </xsl:template>
222
223 <xsl:template match="m:hasA" 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">
233 <xsl:call-template name="getPrimaryKey">
234 <xsl:with-param name="type" select="../@type"/>
235 </xsl:call-template>
236 </xsl:variable>
237 <xsl:variable name="otherKeyExpanded">
238 <xsl:apply-templates select="exsl:node-set($otherKey)" mode="expand-member"/>
239 </xsl:variable>
240 <xsl:variable name="pk" select="exsl:node-set($otherKeyExpanded)[1]"/>
241
242 <m:property name="{@name}" type="{$pk/@type}" hidden="true">
243 <m:related name="{$pk/@name}" type="{../@type}"/>
244 </m:property>
245 </xsl:template>
246
247 <xsl:template match="m:thisKey[m:member | property]">
248 <xsl:apply-templates mode="expand-member"/>
249 </xsl:template>
250
170 </xsl:stylesheet> 251 </xsl:stylesheet>