vb@0: include yslt.yml2 vb@0: vb@0: define operator "†(\S+)" as call "printType" with "name", "%1"; vb@0: define operator "“(.*?)”" as call "ucase" with "text", "%1"; vb@0: vb@0: decl umlstylesheet is tstylesheet ( vb@0: xmlns:uml="http://schema.omg.org/spec/UML/2.1", vb@0: xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" vb@0: ); vb@0: vb@0: umlstylesheet { vb@0: template "/xmi:XMI/uml:Model" vb@0: apply "packagedElement", 0; vb@0: vb@0: template "packagedElement[@xmi:type='uml:Package']" { vb@0: | package «@name»; vb@0: | vb@0: apply "packagedElement", 0; vb@0: } vb@0: vb@0: template "packagedElement[@xmi:type='uml:Class']" { vb@0: | class «@name» { vb@0: apply "ownedAttribute"; vb@0: | } vb@0: if "position() != last()" | vb@0: } vb@0: vb@0: template "ownedAttribute[@xmi:type='uml:Property' and count(@association)=0]" { vb@0: | // attribute «@name» vb@0: | vb@0: | public †type get“@name”() { vb@0: | return «@name»; vb@0: | } vb@0: | vb@0: | public void set“@name”(†type value) { vb@0: | «@name» = value; vb@0: | } vb@0: | vb@0: | private †type «@name»; vb@0: if "position() != last()" | vb@0: } vb@0: vb@0: function "ucase" { vb@0: param "text"; vb@0: vb@0: > «translate(substring($text, 1, 1), 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')» vb@0: > «substring($text, 2)» vb@0: } vb@0: vb@0: function "printType" { vb@0: param "name"; vb@0: vb@0: choose { vb@0: when '$name/@href = "http://schema.omg.org/spec/UML/2.1/uml.xml#UnlimitedNatural"' vb@0: > int vb@0: when '$name/@href = "http://schema.omg.org/spec/UML/2.1/uml.xml#String"' vb@0: > String vb@0: } vb@0: } vb@0: }