/[volute]/trunk/projects/theory/snapdm/res/old-xmi-xslt/html/xmi-to-html.xsl
ViewVC logotype

Contents of /trunk/projects/theory/snapdm/res/old-xmi-xslt/html/xmi-to-html.xsl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 302 - (show annotations)
Mon Apr 28 15:58:36 2008 UTC (12 years, 7 months ago) by gerard.lemson
File MIME type: application/xml
File size: 21369 byte(s)
Added old xmi-to-html.xsl, structures intermediate2xhtml accordingly
1 <?xml version="1.0"?>
2 <!--
3 Title: xmi-to-html.xsl
4 Purpose: An XSL stylesheet for converting ArgoUML 0.80 XMI to HTML.
5
6 Copyright (C) 1999-2001, Objects by Design, Inc. All Rights Reserved.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation. A copy of the license may be found at
11 http://www.objectsbydesign.com/projects/gpl.txt
12
13 Version: January 10, 2001
14
15 For HISTORY and CREDITS, please see the README file.
16
17 -->
18
19 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
20 xmlns="http://www.w3.org/1999/xhtml"
21 version="1.0"
22 exclude-result-prefixes="#default">
23
24 <xsl:output method="xml" indent="yes"
25 doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
26 doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" />
27
28 <xsl:key
29 name="classifier"
30 match="//Foundation.Core.Class|//Foundation.Core.Interface|
31 //Foundation.Core.DataType"
32 use="@xmi.id"/>
33
34 <xsl:key
35 name="generalization"
36 match="//Foundation.Core.Generalization"
37 use="@xmi.id"/>
38
39 <xsl:key
40 name="abstraction"
41 match="//Foundation.Core.Abstraction"
42 use="@xmi.id"/>
43
44 <xsl:key
45 name="multiplicity"
46 match="//Foundation.Data_Types.Multiplicity"
47 use="@xmi.id"/>
48
49
50 <!-- Document Root -->
51 <xsl:template match="/">
52 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
53 <head>
54 <!-- Model Name in window title -->
55 <xsl:apply-templates select="//Model_Management.Model[@xmi.id]" mode="head"/>
56
57 <link href="xmi.css" rel="stylesheet" type="text/css"/>
58 </head>
59 <body>
60
61 <!-- Model Name in document heading -->
62 <xsl:apply-templates select="//Model_Management.Model[@xmi.id]" mode="body"/>
63
64 <!-- Interfaces -->
65 <xsl:apply-templates select="//Foundation.Core.Interface[@xmi.id]">
66 <xsl:sort select="Foundation.Core.ModelElement.name"/>
67 </xsl:apply-templates>
68
69 <!-- Classes -->
70 <xsl:apply-templates select="//Foundation.Core.Class[@xmi.id]">
71 <xsl:sort select="Foundation.Core.ModelElement.name"/>
72 </xsl:apply-templates>
73
74 </body>
75 </html>
76
77 </xsl:template>
78
79
80 <!-- Window Title -->
81 <xsl:template match="Model_Management.Model" mode="head">
82
83 <title>
84 <!-- Name of the model -->
85 <xsl:value-of select="Foundation.Core.ModelElement.name"/>
86 </title>
87
88 </xsl:template>
89
90
91 <!-- Document Heading -->
92 <xsl:template match="Model_Management.Model" mode="body">
93
94 <div align="center">
95 <h1>
96 <!-- Name of the model -->
97 <xsl:value-of select="Foundation.Core.ModelElement.name"/>
98 </h1>
99 </div>
100
101 </xsl:template>
102
103
104 <!-- Class -->
105 <xsl:template match="Foundation.Core.Class">
106 <xsl:variable name="element_name"
107 select="Foundation.Core.ModelElement.name"/>
108
109 <xsl:variable name="xmi_id" select="@xmi.id" />
110
111 <div align="center">
112 <table border="1" width="75%" cellpadding="2" >
113 <tr>
114 <td class="class-title" width="20%">Class</td>
115
116 <!-- create a hyperlink target for the name -->
117 <td class="class-name">
118 <a name="{$element_name}">
119 <xsl:value-of select="$element_name"/>
120 </a>
121 </td>
122 </tr>
123
124 <tr>
125 <td colspan="2" >
126 <table width="100%" cellpadding="0" cellspacing="0" border="0">
127
128 <tr>
129 <td colspan="2" bgcolor="#cacaca">
130 <table width="100%" border="0" cellpadding="3" cellspacing="1">
131
132
133 <xsl:call-template name="specifications"/>
134
135 <xsl:call-template name="realizations"/>
136
137 <xsl:call-template name="supertypes"/>
138
139 <xsl:call-template name="subtypes"/>
140
141 <xsl:call-template name="associations">
142 <xsl:with-param name="source" select="$xmi_id"/>
143 </xsl:call-template>
144
145 <xsl:call-template name="attributes"/>
146
147 <xsl:call-template name="operations"/>
148
149 </table>
150 </td>
151 </tr>
152
153 </table>
154 </td>
155 </tr>
156
157 </table>
158 </div>
159 <br /><br />
160 </xsl:template>
161
162
163 <!-- Interface -->
164 <xsl:template match="Foundation.Core.Interface">
165 <xsl:variable name="element_name"
166 select="Foundation.Core.ModelElement.name"/>
167
168 <div align="center">
169 <table border="1" width="75%" cellpadding="2" >
170 <tr>
171 <td class="interface-title" width="20%">Interface</td>
172
173 <!-- create a hyperlink target for the name -->
174 <td class="interface-name">
175 <a name="{$element_name}">
176 <xsl:value-of select="$element_name"/>
177 </a>
178 </td>
179 </tr>
180
181 <tr>
182 <td colspan="2" >
183 <table width="100%" cellpadding="0" cellspacing="0" border="0">
184
185 <tr>
186 <td colspan="2" bgcolor="#cacaca">
187 <table width="100%" border="0" cellpadding="3" cellspacing="1">
188
189 <xsl:call-template name="realizations"/>
190
191 <xsl:call-template name="supertypes"/>
192
193 <xsl:call-template name="subtypes"/>
194
195 <xsl:call-template name="operations"/>
196
197 </table>
198 </td>
199 </tr>
200
201 </table>
202 </td>
203 </tr>
204
205 </table>
206 </div>
207 <br/><br/>
208 </xsl:template>
209
210
211 <!-- The following template is designed to be called for Abstractions with the "realize"
212 stereotype, i.e. Realization relationships. It formats the name of the supplier of the
213 Abstraction dependency, i.e. the class or interface specifying the behaviour of the
214 client in the dependency.
215 -->
216 <!-- Specifications (interface or class) -->
217 <xsl:template name="specifications">
218
219 <!-- Abstractions identify specifications -->
220 <xsl:variable name="specifications"
221 select="Foundation.Core.ModelElement.clientDependency/
222 Foundation.Core.Abstraction"/>
223
224 <xsl:if test="count($specifications) > 0">
225 <tr>
226 <td width="20%" class="info-title">Specifications:</td>
227 <td colspan="2" class="info">
228 <xsl:for-each select="$specifications">
229
230 <!-- get the supplier in the abstraction -->
231 <xsl:variable name="abstraction"
232 select="key('abstraction', ./@xmi.idref)" />
233 <xsl:variable name="target"
234 select="$abstraction/
235 Foundation.Core.Dependency.supplier/
236 */@xmi.idref" />
237 <xsl:call-template name="classify">
238 <xsl:with-param name="target" select="$target"/>
239 </xsl:call-template>
240
241 <xsl:if test="position() != last()">
242 <xsl:text>, </xsl:text>
243 </xsl:if>
244 </xsl:for-each>
245 </td>
246 </tr>
247 </xsl:if>
248
249 </xsl:template>
250
251
252 <!-- The following template is designed to be called for Abstractions with the "realize"
253 stereotype, i.e. Realization relationships. It formats the name of the client of the
254 Abstraction dependency, i.e. the class realizing the specification defined by the
255 supplier in the dependency.
256 -->
257 <!-- Realizations (of interface) -->
258 <xsl:template name="realizations">
259
260 <!-- Abstractions identify realizations -->
261 <xsl:variable name="realizations"
262 select="Foundation.Core.ModelElement.supplierDependency/
263 Foundation.Core.Abstraction"/>
264
265 <xsl:if test="count($realizations) > 0">
266 <tr>
267 <td width="20%" class="info-title">Realizations:</td>
268 <td colspan="2" class="info">
269 <xsl:for-each select="$realizations">
270
271 <!-- get the client in the abstraction -->
272 <xsl:variable name="abstraction"
273 select="key('abstraction', ./@xmi.idref)" />
274 <xsl:variable name="target"
275 select="$abstraction/
276 Foundation.Core.Dependency.client/
277 */@xmi.idref" />
278 <xsl:call-template name="classify">
279 <xsl:with-param name="target" select="$target"/>
280 </xsl:call-template>
281
282 <xsl:if test="position() != last()">
283 <xsl:text>, </xsl:text>
284 </xsl:if>
285 </xsl:for-each>
286 </td>
287 </tr>
288 </xsl:if>
289
290 </xsl:template>
291
292
293
294 <!-- Supertypes (inheritance) -->
295 <xsl:template name="supertypes">
296
297 <!-- Generalizations identify supertypes -->
298 <xsl:variable name="generalizations"
299 select="Foundation.Core.GeneralizableElement.generalization/
300 Foundation.Core.Generalization"/>
301
302 <xsl:if test="count($generalizations) > 0">
303 <tr>
304 <td width="20%" class="info-title">Supertypes:</td>
305 <td colspan="2" class="info">
306 <xsl:for-each select="$generalizations">
307
308 <!-- get the parent in the generalization -->
309 <xsl:variable name="generalization"
310 select="key('generalization', ./@xmi.idref)" />
311 <xsl:variable name="target"
312 select="$generalization/
313 Foundation.Core.Generalization.parent/
314 */@xmi.idref" />
315 <xsl:call-template name="classify">
316 <xsl:with-param name="target" select="$target"/>
317 </xsl:call-template>
318
319 <xsl:if test="position() != last()">
320 <xsl:text>, </xsl:text>
321 </xsl:if>
322 </xsl:for-each>
323 </td>
324 </tr>
325 </xsl:if>
326 </xsl:template>
327
328
329 <!-- Subtypes (inheritance) -->
330 <xsl:template name="subtypes">
331
332 <!-- Specializations identify subtypes -->
333 <xsl:variable name="specializations"
334 select="Foundation.Core.GeneralizableElement.specialization/
335 Foundation.Core.Generalization"/>
336
337 <xsl:if test="count($specializations) > 0">
338 <tr>
339 <td width="20%" class="info-title">Subtypes:</td>
340 <td colspan="2" class="info">
341 <xsl:for-each select="$specializations">
342
343 <!-- get the child in the generalization -->
344 <xsl:variable name="generalization"
345 select="key('generalization', ./@xmi.idref)" />
346 <xsl:variable name="target"
347 select="$generalization/
348 Foundation.Core.Generalization.child/
349 */@xmi.idref" />
350 <xsl:call-template name="classify">
351 <xsl:with-param name="target" select="$target"/>
352 </xsl:call-template>
353
354 <xsl:if test="position() != last()">
355 <xsl:text>, </xsl:text>
356 </xsl:if>
357 </xsl:for-each>
358 </td>
359 </tr>
360 </xsl:if>
361 </xsl:template>
362
363
364 <!-- Associations -->
365 <xsl:template name="associations">
366 <xsl:param name="source"/>
367
368 <xsl:variable name="association_ends"
369 select="//Foundation.Core.AssociationEnd
370 [Foundation.Core.AssociationEnd.type/*/
371 @xmi.idref=$source]" />
372
373 <xsl:if test="count($association_ends) > 0">
374 <tr>
375 <td colspan="3" class="info-title">Associations:</td>
376 </tr>
377 <tr>
378 <td class="feature-heading" width="20%">visibility</td>
379 <td class="feature-heading" width="25%">type</td>
380 <td class="feature-heading" width="55%">properties</td>
381 </tr>
382
383 <xsl:for-each select="$association_ends">
384 <tr>
385 <xsl:for-each select="preceding-sibling::Foundation.Core.AssociationEnd |
386 following-sibling::Foundation.Core.AssociationEnd">
387
388 <xsl:call-template name="association_end" />
389
390 </xsl:for-each>
391 </tr>
392 </xsl:for-each>
393 </xsl:if>
394 </xsl:template>
395
396
397 <!-- Association End -->
398 <xsl:template name="association_end">
399 <!-- Visibility -->
400 <td class="feature-detail">
401 <xsl:variable name="visibility"
402 select="Foundation.Core.ModelElement.visibility" />
403 <xsl:choose>
404 <xsl:when test="string-length($visibility) > 0">
405 <xsl:value-of select="$visibility"/>
406 </xsl:when>
407 <xsl:otherwise>
408 <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
409 </xsl:otherwise>
410 </xsl:choose>
411 </td>
412
413 <!-- Type -->
414 <td class="feature-detail">
415 <xsl:variable name="target"
416 select="Foundation.Core.AssociationEnd.type/*/@xmi.idref" />
417
418 <xsl:call-template name="classify">
419 <xsl:with-param name="target" select="$target"/>
420 </xsl:call-template>
421 </td>
422
423 <!-- Properties -->
424 <td class="feature-detail">
425
426 <!-- Rolename -->
427 <xsl:variable name="rolename"
428 select="Foundation.Core.ModelElement.name"/>
429
430 <span class="property-name">Rolename: </span>
431 <xsl:choose>
432 <xsl:when test="string-length($rolename) > 0">
433 <xsl:value-of select="$rolename"/>
434 </xsl:when>
435 <xsl:otherwise>(none)</xsl:otherwise>
436 </xsl:choose>
437
438 <!-- Multiplicity -->
439 <xsl:apply-templates select=".//Foundation.Data_Types.Multiplicity" />
440
441 <!-- Navigable -->
442 <xsl:variable name="navigable"
443 select="Foundation.Core.AssociationEnd.isNavigable/@xmi.value"/>
444 <xsl:if test="string-length($navigable) > 0">
445 <br />
446 <span class="property-name">Navigable: </span>
447 <xsl:value-of select="$navigable"/>
448 </xsl:if>
449
450 <!-- Ordering -->
451 <xsl:variable name="ordering"
452 select="Foundation.Core.AssociationEnd.ordering/@xmi.value"/>
453 <xsl:if test="string-length($ordering) > 0">
454 <br />
455 <span class="property-name">Ordering: </span>
456 <xsl:value-of select="$ordering"/>
457 </xsl:if>
458 </td>
459 </xsl:template>
460
461
462 <!-- Multiplicity (definition) -->
463 <xsl:template match="Foundation.Data_Types.Multiplicity[@xmi.id]">
464 <br />
465 <span class="property-name">Multiplicity: </span>
466
467 <xsl:variable name="lower"
468 select=".//Foundation.Data_Types.MultiplicityRange.lower"/>
469
470 <xsl:variable name="upper"
471 select=".//Foundation.Data_Types.MultiplicityRange.upper"/>
472
473 <xsl:value-of select="$lower" />
474 <xsl:if test="$upper != $lower">
475 <xsl:text>..</xsl:text>
476 <xsl:value-of select="$upper" />
477 </xsl:if>
478
479 </xsl:template>
480
481 <!-- Multiplicity (reference) -->
482 <xsl:template match="Foundation.Data_Types.Multiplicity[@xmi.idref]">
483 <xsl:apply-templates
484 select="key('multiplicity', @xmi.idref)" />
485 </xsl:template>
486
487
488
489 <!-- Attributes -->
490 <xsl:template name="attributes">
491 <tr>
492 <td colspan="3" class="info-title">Attributes:</td>
493 </tr>
494 <tr>
495 <td class="feature-heading" width="20%">visibility</td>
496 <td class="feature-heading" width="25%">type</td>
497 <td class="feature-heading" width="55%">name</td>
498 </tr>
499 <xsl:apply-templates select="Foundation.Core.Classifier.feature/
500 Foundation.Core.Attribute" />
501 </xsl:template>
502
503
504 <xsl:template match="Foundation.Core.Attribute">
505 <xsl:variable name="target"
506 select='Foundation.Core.StructuralFeature.type/*/@xmi.idref'/>
507
508
509 <tr>
510 <td class="feature-detail">
511 <xsl:value-of select="Foundation.Core.ModelElement.visibility/@xmi.value"/>
512 </td>
513
514 <td class="feature-detail">
515 <xsl:call-template name="classify">
516 <xsl:with-param name="target" select="$target" />
517 </xsl:call-template>
518 </td>
519
520 <td class="feature-detail">
521 <xsl:value-of select="Foundation.Core.ModelElement.name"/>
522 </td>
523 </tr>
524 </xsl:template>
525
526
527
528 <!-- Operations -->
529 <xsl:template name="operations">
530 <tr>
531 <td colspan="3" class="info-title">Operations:</td>
532 </tr>
533 <tr>
534 <td class="feature-heading" width="20%">visibility</td>
535 <td class="feature-heading" width="25%">return</td>
536 <td class="feature-heading" width="55%">name</td>
537 </tr>
538
539 <xsl:apply-templates select="Foundation.Core.Classifier.feature/
540 Foundation.Core.Operation" />
541 </xsl:template>
542
543
544 <xsl:template match="Foundation.Core.Operation">
545
546 <xsl:variable name="parameters"
547 select="Foundation.Core.BehavioralFeature.parameter/
548 Foundation.Core.Parameter
549 [Foundation.Core.Parameter.kind/@xmi.value!='return']" />
550
551 <xsl:variable name="return"
552 select="Foundation.Core.BehavioralFeature.parameter/
553 Foundation.Core.Parameter
554 [Foundation.Core.Parameter.kind/@xmi.value='return']" />
555
556 <xsl:variable name="target"
557 select="$return/Foundation.Core.Parameter.type/*/@xmi.idref" />
558
559 <tr>
560 <td class="feature-detail">
561 <xsl:value-of select="Foundation.Core.ModelElement.visibility/@xmi.value" />
562 </td>
563
564 <td class="feature-detail">
565
566 <xsl:choose>
567 <xsl:when test="string-length($target) = 0">
568 <span class="datatype"><xsl:text>void</xsl:text></span>
569 </xsl:when>
570
571 <xsl:otherwise>
572 <xsl:call-template name="classify">
573 <xsl:with-param name="target" select="$target" />
574 </xsl:call-template>
575 </xsl:otherwise>
576 </xsl:choose>
577
578 </td>
579
580 <td class="feature-detail">
581 <xsl:value-of select="Foundation.Core.ModelElement.name"/>
582 </td>
583 </tr>
584
585 <xsl:variable name="parameter-count" select="count($parameters)" />
586
587 <xsl:if test="not(normalize-space($parameter-count)='0')">
588
589 <tr>
590 <td class="feature-detail" >
591 <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
592 </td>
593
594 <td class="parameter-heading" valign="top">parameters:</td>
595 <td bgcolor="#ffffff" align="right">
596 <table width="85%" align="right" cellpadding="0" cellspacing="0" border="0">
597 <xsl:apply-templates select="$parameters" />
598 </table>
599 </td>
600 </tr>
601
602 </xsl:if >
603
604 </xsl:template>
605
606
607
608 <!-- Parameter -->
609 <xsl:template match="Foundation.Core.Parameter">
610 <xsl:variable name="target"
611 select="Foundation.Core.Parameter.type/*/@xmi.idref" />
612
613 <tr>
614 <td class="feature-detail" width="45%">
615 <xsl:call-template name="classify">
616 <xsl:with-param name="target" select="$target" />
617 </xsl:call-template>
618 </td>
619
620 <td class="feature-detail" width="55%">
621 <xsl:value-of select="Foundation.Core.ModelElement.name"/>
622 </td>
623 </tr>
624 </xsl:template>
625
626
627 <!-- Classification -->
628 <xsl:template name="classify">
629 <xsl:param name="target"/>
630
631 <xsl:variable name="classifier"
632 select="key('classifier', $target)" />
633
634 <xsl:variable name="classifier_name"
635 select="$classifier/Foundation.Core.ModelElement.name" />
636
637 <xsl:variable name="type" select="name($classifier)" />
638
639 <!-- Get the type of the classifier (class, interface, datatype) -->
640 <xsl:variable name="classifier_type">
641 <xsl:choose>
642 <xsl:when test="$type='Foundation.Core.Class'">classifier</xsl:when>
643 <xsl:when test="$type='Foundation.Core.Interface'">interface</xsl:when>
644 <xsl:when test="$type='Foundation.Core.DataType'">datatype</xsl:when>
645 <xsl:otherwise>classifier</xsl:otherwise>
646 </xsl:choose>
647 </xsl:variable>
648
649 <xsl:choose>
650 <!-- Datatypes don't have hyperlinks -->
651 <xsl:when test="$type='Foundation.Core.DataType'">
652 <span class="datatype">
653 <xsl:value-of select="$classifier_name"/>
654 </span>
655 </xsl:when>
656
657 <!-- Classes and Interfaces have hyperlinks -->
658 <!-- The classifier type is used to style appropriately -->
659 <xsl:otherwise>
660 <xsl:if test="string-length($classifier) > 0">
661 <a class="{$classifier_type}" href="#{$classifier_name}">
662 <xsl:value-of select="$classifier_name"/>
663 </a>
664 </xsl:if>
665 </xsl:otherwise>
666 </xsl:choose>
667
668 </xsl:template>
669
670 </xsl:stylesheet>

msdemlei@ari.uni-heidelberg.de
ViewVC Help
Powered by ViewVC 1.1.26