vb@0: include yslt.yml2 vb@0: vb@0: define operator "“(.*?)”" as call "idl2ddl" with "type", "%1"; vb@0: vb@0: tstylesheet { vb@0: const "idtype", "'INTEGER'"; vb@0: vb@0: template "/" apply "module|class", 0; vb@0: vb@0: template "module" { vb@0: param "namespace", "''"; vb@0: choose { vb@0: when "$namespace=''" vb@0: apply "module|class", 0 with "namespace", "@name"; vb@0: otherwise vb@0: apply "module|class", 0 with "namespace", "concat($namespace,'_', @name)"; vb@0: } vb@0: } vb@0: vb@0: template "class" { vb@0: param "namespace", "''"; vb@0: vb@0: choose { vb@0: when "$namespace=''" | CREATE TABLE «@name» ( vb@0: otherwise | CREATE TABLE «$namespace»_«@name» ( vb@0: } vb@0: vb@0: if "count(attr[@name='id'])=0" |> id «$idtype»`if "count(attr)>0" > , ` vb@0: vb@0: const "name", "@name"; vb@0: foreach "//class[class/@name=$name]" |> «@name»_fk «$idtype», vb@0: vb@0: apply "attr"; vb@0: vb@0: | ); vb@0: vb@0: apply "class", 0 with "namespace", "$namespace"; vb@0: } vb@0: vb@0: template "attr" | «@name» “@type”`if "position() != last()" > , ` vb@0: vb@0: function "idl2ddl" { vb@0: param "type"; vb@0: vb@0: choose { vb@0: when "$type='string'" > VARCHAR vb@0: when "$type='long'" > INTEGER vb@0: } vb@0: } vb@0: }