sync/gen_dot.ysl2
changeset 2271 25bfd109320c
child 2287 026ab4dae779
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/sync/gen_dot.ysl2	Fri Nov 03 13:32:38 2017 +0100
     1.3 @@ -0,0 +1,42 @@
     1.4 +// This file is under GNU General Public License 3.0
     1.5 +// see LICENSE.txt
     1.6 +
     1.7 +include yslt.yml2
     1.8 +
     1.9 +tstylesheet {
    1.10 +    template "protocol/fsm" document "{@filename}.dot", "text"
    1.11 +    ||
    1.12 +    digraph finite_state_machine {
    1.13 +        rankdir=LR;
    1.14 +        node [shape = doublecircle];
    1.15 +        `apply "state[@end='1']" mode=end`;
    1.16 +        node [shape = circle];
    1.17 +
    1.18 +        `` apply "state" mode=do
    1.19 +    }
    1.20 +    ||
    1.21 +
    1.22 +    template "state", mode=end > «@name» 
    1.23 +    template "state", mode=do apply "event", 0 with "state", "@name";
    1.24 +
    1.25 +    template "event" {
    1.26 +        param "state";
    1.27 +        const "transitions", "transition|descendant::condition/transition|descendant::alternative/transition";
    1.28 +        choose {
    1.29 +            when "count($transitions) > 0"
    1.30 +                apply "$transitions", 0
    1.31 +                    with "state", "$state", with "event", "@name";
    1.32 +            otherwise
    1.33 +                if "@name != 'Init'"
    1.34 +                    | «$state» -> «$state» [ label="«@name»" ];
    1.35 +        }
    1.36 +    }
    1.37 +
    1.38 +    template "transition" {
    1.39 +        param "state";
    1.40 +        param "event";
    1.41 +
    1.42 +        | «$state» -> «@target» [ label ="«$event»" ];
    1.43 +    }
    1.44 +}
    1.45 +