%D \module
%D   [       file=m-steps,
%D        version=2001.05.28,
%D          title=\CONTEXT\ Modules,
%D       subtitle=Step Charts \& Tables,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D The \XML\ interface:

\usemodule[m][steps]

\unprotect

\defineXMLdirective [stepchart] [charts] \setupSTEPcharts
\defineXMLdirective [stepchart] [cells]  \setupSTEPcells
\defineXMLdirective [stepchart] [texts]  \setupSTEPtexts
\defineXMLdirective [stepchart] [lines]  \setupSTEPlines

\defineXMLdirective [steptable] [tables] \setupSTEPtables
\defineXMLdirective [steptable] [cells]  \setupSTEPcells
\defineXMLdirective [steptable] [texts]  \setupSTEPtexts
\defineXMLdirective [steptable] [lines]  \setupSTEPlines

\defineXMLpickup[stepchart][@@STPC]
  {\bgroup
   \defineXMLpush[top]%
   \defineXMLpush[bot]%
   \defineXMLenvironment[lines][@@STEL]
     {\expanded{\startlines[\theXMLarguments{@@STEL}]}}
     {\stoplines}%
   \defineXMLenvironment[cells][@@STEC]
     {\XMLerase{top}\XMLerase{bot}}
     {\expanded{\cells[\theXMLarguments{@@STEC}]{\XMLpop{top}}{\XMLpop{bot}}}}%
   \defineXMLenvironment[texts][@@STET]
     {\XMLerase{top}\XMLerase{bot}}
     {\expanded{\texts[\theXMLarguments{@@STET}]{\XMLpop{top}}{\XMLpop{bot}}}}%
   \defineXMLenvironmentpush[cell][@@STEC]
     {\XMLerase{cell}}
     {\expanded{\cell [\theXMLarguments{@@STEC}]{\XMLpop{cell}}}}%
   \defineXMLenvironmentpush [text] [@@STET]
     {\XMLerase{text}}
     {\expanded{\text [\theXMLarguments{@@STET}]{\XMLpop{text}}}}%
   \expanded{\startSTEPchart[\theXMLarguments{@@STPC}]}}
  {\stopSTEPchart
   \egroup}

\defineXMLpickup[steptable][@@STPT]
  {\bgroup
   \defineXMLenvironment[lines][@@STEL]
     {\expanded{\startlines[\theXMLarguments{@@STEL}]}}
     {\stoplines}%
   \defineXMLargument[cell][@@STEC]
     {\expanded{\cell[\theXMLarguments{@@STEC}]}}%
   \defineXMLargument[text][@@STET]
     {\expanded{\text[\theXMLarguments{@@STET}]}}%
   \defineXMLargument[prep]
     {\prep}%
   \expanded{\startSTEPtable[\theXMLarguments{@@STPT}]}}
  {\stopSTEPtable
   \egroup}

\defineXMLpickup[stepaligntable][@@STPT]
  {\bgroup
    \defineXMLenvironment[lines][@@STEL]
      {\expanded{\setupSTEPlines[\theXMLarguments{@@STEL}]}}
      {}%
   \defineXMLpush[c1]\defineXMLpush[c2]\defineXMLpush[c3]%
   \defineXMLenvironment[cells][@@STEC]
     {\XMLerase{c1}\XMLerase{c1}\XMLerase{c3}}
     {\expanded{\cells[\theXMLarguments{@@STEC}]{\XMLpop{c1}}{\XMLpop{c2}}{\XMLpop{c3}}}}%
   \defineXMLargument[text][@@STET]
     {\expanded{\text[\theXMLarguments{@@STET}]}}%
   \defineXMLargument[prep]
     {\prep}%
   \expanded{\startSTEPaligntable[\theXMLarguments{@@STPT}]}}
  {\stopSTEPaligntable
   \egroup}

\protect \endinput
