% output=pdftex interface=en

\usemodule[chart,mathml,steps]

\setupcolors[state=start] \setupbodyfont[lbr,8pt]
\setuplayout[width=middle,height=middle,backspace=1cm,topspace=1cm,header=0pt,footer=0pt]

\startbuffer[xml]
<flowchartdefinition identifier="test">
  <?context-flowchart-directive lines color darkgreen ?>
  <flowcell>
    <name> tex </name>
    <location> <x> 1 </x> <y> 1 </y> </location>
    <shape> action </shape>
    <text> &tex; </text>
    <connection> <type> rl </type> <name> context </name> </connection>
  </flowcell>
  <?context-begin-group a very important cell ?>
  <?context-flowchart-directive shapes framecolor darkred ?>
  <flowcell>
    <?context-flowchart-directive lines color darkyellow ?>
    <name> context </name>
    <location> <x> 2 </x> <y> 1 </y> </location>
    <shape> action </shape>
    <text>
      <stepchart>
        <cell> one   </cell> <text> even </text>
        <cell> two   </cell> <text> odd  </text>
        <cell> three </cell>
      </stepchart>
    </text>
    <connection> <type> rl </type> <name> rubish </name> </connection>
  </flowcell>
  <?context-end-group a very important cell ?>
  <flowcell>
    <name> rubish </name>
    <location> <x> 1 </x> <y> 2 </y> </location>
    <shape> action </shape>
    <text> <m> 1+2=3 </m> </text>
    <connection> <type> rl </type> <name> another </name> </connection>
  </flowcell>
  <flowcell>
    <?context-flowchart-directive lines color darkblue ?>
    <name> another </name>
    <location> <x> 2 </x> <y> 2 </y> </location>
    <shape> action </shape>
    <text>
      <math> <apply> <sin/> <apply> <plus/>
        <cn> 2 </cn> <ci> a </ci>
      </apply> </apply> </math>
    </text>
    <connection> <type> bt </type> <name> tex </name> </connection>
  </flowcell>
</flowchartdefinition>

<flowchart identifier="test"/>
\stopbuffer

\startbuffer[tex]
\startFLOWchart [test]
  \setupFLOWlines[color=darkgreen]
  \startFLOWcell 
    \name{tex}
    \location{1,1}
    \shape{action}
    \text{\TeX}
    \connect[rl]{context}
  \stopFLOWcell 
  \start
  \setupFLOWshapes[framecolor=darkred]
  \startFLOWcell 
    \setupFLOWlines[color=darkyellow]
    \name{context}
    \location{2,1}
    \shape{action}
    \text
      {\startSTEPchart
         \cell{one}  \text{even}
         \cell{two}  \text{odd}
         \cell{three} 
       \stopSTEPchart}
    \connect[rl]{rubish}
  \stopFLOWcell 
  \stop
  \startFLOWcell 
    \name{rubish}
    \location{1,2}
    \shape{action}
    \text{$1+2=3$}
    \connect[rl]{another}
  \stopFLOWcell 
  \startFLOWcell 
    \setupFLOWlines[color=darkblue]
    \name{another}
    \location{2,2}
    \shape{action}
    \text{$\sin(2+a)$}
    \connect[bt]{tex}
  \stopFLOWcell 
\stopFLOWchart

\FLOWchart[test]
\stopbuffer

\starttext

\processXMLbuffer[xml] \typebuffer[xml] \page 

\getbuffer[tex] \typebuffer[tex]

\stoptext
