samples/xmi2ddl.ysl2
changeset 0 76005e62091d
equal deleted inserted replaced
-1:000000000000 0:76005e62091d
       
     1 include yslt.yml2
       
     2 
       
     3 tstylesheet xmlns:uml="http://schema.omg.org/spec/UML/2.1",
       
     4             xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" {
       
     5 
       
     6     template "/" apply "xmi:XMI/uml:Model/packagedElement", 0;
       
     7 
       
     8     template "packagedElement[@xmi:type='uml:Package']" {
       
     9         param "name", "''";
       
    10         if "$name=''"  apply "packagedElement", 0 { with "name", "@name"; }
       
    11         if "$name!=''" apply "packagedElement", 0 { with "name", "concat($name, '_', @name)"; }
       
    12     }
       
    13 
       
    14     template "packagedElement[@xmi:type='uml:Class']" {
       
    15         param "name";
       
    16 
       
    17         | CREATE TABLE «$name»_«@name» (
       
    18         apply "ownedAttribute";
       
    19         | );
       
    20     }
       
    21 
       
    22     template "ownedAttribute[@xmi:type='uml:Property' and type/@xmi:type='uml:PrimitiveType']" {
       
    23         0> «@name»
       
    24         choose {
       
    25             when "type/@href='http://schema.omg.org/spec/UML/2.1/uml.xml#String'"
       
    26                 >  VARCHAR
       
    27 
       
    28             // [...] for other types, extend when clauses
       
    29         }
       
    30         if "position()!=last()" > ,
       
    31         text "\n";
       
    32     }
       
    33 }
       
    34