samples/uml.yml2
author Edouard Tisserant <edouard.tisserant@gmail.com>
Wed, 28 Apr 2021 23:40:51 +0200
changeset 78 0b05c2bce9e4
parent 0 76005e62091d
permissions -rw-r--r--
Fix expension of macros in pointers with default values.

For example :

in xsl decl widget_class(%name, *clsname="%nameWidget", match="widget[@type='%name']", mode="widget_class") alias template {
| class `text **clsname` extends Widget{
content;
| }
};

widget_class('Input');

gives now :

<xsl:template match="widget[@type='Input']" mode="widget_class">
<xsl:text>class </xsl:text>
<xsl:text>InputWidget</xsl:text>
<xsl:text> extends Widget{
</xsl:text>
<xsl:text>}
</xsl:text>
</xsl:template>

Without the fix, <xsl:text>InputWidget</xsl:text> would be <xsl:text>%nameWidget</xsl:text>
0
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
     1
include yslt.yml2
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
     2
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
     3
decl UML is textstylesheet(
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
     4
    xmlns:uml="http://schema.omg.org/spec/UML/2.1",
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
     5
    xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" 
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
     6
) {
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
     7
    output *output;
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
     8
    const "space", !"'" + " " * 200 + "'"!;
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
     9
    param "autoindent", 4;
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    10
    template "text()";
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    11
    content;
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    12
};
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    13
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    14
decl Root is template(match="/xmi:XMI/uml:Model/packagedElement"),
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    15
     All  is template(%match="*", match="//[%match]");
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    16
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    17
decl Package is template(
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    18
    %match="true()",
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    19
    match="packagedElement[@xmi:type='uml:Package' and (%match)]"
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    20
);
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    21
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    22
decl applyPackages is apply (
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    23
    %match="true()",
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    24
    select="packagedElement[@xmi:type='uml:Package' and (%match)]"
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    25
);
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    26
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    27
decl Class is template(
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    28
    %match="true()",
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    29
    match="packagedElement[@xmi:type='uml:Class' and (%match)]"
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    30
);
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    31
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    32
decl applyClasses is apply (
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    33
    %match="true()",
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    34
    select="packagedElement[@xmi:type='uml:Class' and (%match)]"
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    35
);
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    36
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    37
decl Attribute is template(
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    38
    %match="true()",
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    39
    match="ownedAttribute[@xmi:type='uml:Property' and type/@xmi:type='uml:PrimitiveType' and (%match)]"
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    40
);
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    41
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    42
decl applyAttributes is apply (
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    43
    %match="true()",
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    44
    select="ownedAttribute[@xmi:type='uml:Property' and type/@xmi:type='uml:PrimitiveType' and (%match)]"
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    45
);
76005e62091d initial commit
Volker Birk <vb@pep-project.org>
parents:
diff changeset
    46