0
|
1 |
include yslt.yml2
|
|
2 |
|
|
3 |
define operator "†(\S+)" as call "printType" with "name", "%1";
|
|
4 |
define operator "“(.*?)”" as call "ucase" with "text", "%1";
|
|
5 |
|
|
6 |
decl umlstylesheet is tstylesheet (
|
|
7 |
xmlns:uml="http://schema.omg.org/spec/UML/2.1",
|
|
8 |
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
|
|
9 |
);
|
|
10 |
|
|
11 |
umlstylesheet {
|
|
12 |
template "/xmi:XMI/uml:Model"
|
|
13 |
apply "packagedElement", 0;
|
|
14 |
|
|
15 |
template "packagedElement[@xmi:type='uml:Package']" {
|
|
16 |
| package «@name»;
|
|
17 |
|
|
|
18 |
apply "packagedElement", 0;
|
|
19 |
}
|
|
20 |
|
|
21 |
template "packagedElement[@xmi:type='uml:Class']" {
|
|
22 |
| class «@name» {
|
|
23 |
apply "ownedAttribute";
|
|
24 |
| }
|
|
25 |
if "position() != last()" |
|
|
26 |
}
|
|
27 |
|
|
28 |
template "ownedAttribute[@xmi:type='uml:Property' and count(@association)=0]" {
|
|
29 |
| // attribute «@name»
|
|
30 |
|
|
|
31 |
| public †type get“@name”() {
|
|
32 |
| return «@name»;
|
|
33 |
| }
|
|
34 |
|
|
|
35 |
| public void set“@name”(†type value) {
|
|
36 |
| «@name» = value;
|
|
37 |
| }
|
|
38 |
|
|
|
39 |
| private †type «@name»;
|
|
40 |
if "position() != last()" |
|
|
41 |
}
|
|
42 |
|
|
43 |
function "ucase" {
|
|
44 |
param "text";
|
|
45 |
|
|
46 |
> «translate(substring($text, 1, 1), 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')»
|
|
47 |
> «substring($text, 2)»
|
|
48 |
}
|
|
49 |
|
|
50 |
function "printType" {
|
|
51 |
param "name";
|
|
52 |
|
|
53 |
choose {
|
|
54 |
when '$name/@href = "http://schema.omg.org/spec/UML/2.1/uml.xml#UnlimitedNatural"'
|
|
55 |
> int
|
|
56 |
when '$name/@href = "http://schema.omg.org/spec/UML/2.1/uml.xml#String"'
|
|
57 |
> String
|
|
58 |
}
|
|
59 |
}
|
|
60 |
}
|