%D \module
%D   [       file=catc-xml,
%D        version=2006.09.18,
%D          title=\CONTEXT\ Catcode Macros,
%D       subtitle=\XML\ Catcode 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.

\writestatus{loading}{ConTeXt Catcode Regimes / XML}

\ifdefined \xmlcatcodesn \else \newcatcodetable \xmlcatcodesn \fi % normal
\ifdefined \xmlcatcodese \else \newcatcodetable \xmlcatcodese \fi % entitle
\ifdefined \xmlcatcodesr \else \newcatcodetable \xmlcatcodesr \fi % reduce

\startcatcodetable \xmlcatcodesn
    \catcode\tabasciicode       \spacecatcode
    \catcode\endoflineasciicode \endoflinecatcode
    \catcode\formfeedasciicode  \endoflinecatcode
    \catcode\spaceasciicode     \spacecatcode
    \catcode\endoffileasciicode \ignorecatcode
    \catcode\ampersandasciicode \activecatcode
    \catcode`\<                 \activecatcode
    \catcode`\>                 \othercatcode
    \catcode`\"                 \othercatcode % probably not needed any more
    \catcode`\/                 \othercatcode % probably not needed any more
    \catcode`\'                 \othercatcode % probably not needed any more
    \catcode\tildeasciicode     \othercatcode % probably not needed any more
    \catcode\hashasciicode      \othercatcode % probably not needed any more
    \catcode\backslashasciicode \othercatcode % probably not needed any more
\stopcatcodetable

\startcatcodetable \xmlcatcodese
    \catcode\tabasciicode       \spacecatcode
    \catcode\endoflineasciicode \endoflinecatcode
    \catcode\formfeedasciicode  \endoflinecatcode
    \catcode\spaceasciicode     \spacecatcode
    \catcode\endoffileasciicode \ignorecatcode
    \catcode\ampersandasciicode \activecatcode
    \catcode`\<                 \activecatcode
    \catcode`\>                 \activecatcode
    \catcode\hashasciicode      \activecatcode
    \catcode\dollarasciicode    \activecatcode
    \catcode\commentasciicode   \activecatcode
    \catcode\backslashasciicode \activecatcode
    \catcode\circumflexasciicode\activecatcode
    \catcode\underscoreasciicode\activecatcode
    \catcode\leftbraceasciicode \activecatcode
    \catcode\rightbraceasciicode\activecatcode
    \catcode\barasciicode       \activecatcode
    \catcode\tildeasciicode     \activecatcode
\stopcatcodetable

\startcatcodetable \xmlcatcodesr
    \catcode\tabasciicode       \spacecatcode
    \catcode\endoflineasciicode \endoflinecatcode
    \catcode\formfeedasciicode  \endoflinecatcode
    \catcode\spaceasciicode     \spacecatcode
    \catcode\endoffileasciicode \ignorecatcode
    \catcode\ampersandasciicode \activecatcode
    \catcode`\<                 \activecatcode
    \catcode`\>                 \activecatcode
    \catcode\hashasciicode      \activecatcode
    \catcode\dollarasciicode    \activecatcode
    \catcode\commentasciicode   \activecatcode
    \catcode\backslashasciicode \activecatcode
    \catcode\circumflexasciicode\activecatcode
    \catcode\underscoreasciicode\activecatcode
    \catcode\leftbraceasciicode \activecatcode
    \catcode\rightbraceasciicode\activecatcode
    \catcode\barasciicode       \activecatcode
    \catcode\tildeasciicode     \activecatcode
\stopcatcodetable

%D Next we hook in some active character definitions.

\letcatcodecommand \xmlcatcodesn \ampersandasciicode  \relax
\letcatcodecommand \xmlcatcodesn `\<                  \relax

\letcatcodecommand \xmlcatcodese \ampersandasciicode  \relax
\letcatcodecommand \xmlcatcodese `\<                  \relax

\letcatcodecommand \xmlcatcodesr \ampersandasciicode  \relax
\letcatcodecommand \xmlcatcodesr `\<                  \relax

\letcatcodecommand \xmlcatcodese \hashasciicode       \relax
\letcatcodecommand \xmlcatcodese \dollarasciicode     \relax
\letcatcodecommand \xmlcatcodese \commentasciicode    \relax
\letcatcodecommand \xmlcatcodese \backslashasciicode  \relax
\letcatcodecommand \xmlcatcodese \circumflexasciicode \relax
\letcatcodecommand \xmlcatcodese \underscoreasciicode \relax
\letcatcodecommand \xmlcatcodese \leftbraceasciicode  \relax
\letcatcodecommand \xmlcatcodese \rightbraceasciicode \relax
\letcatcodecommand \xmlcatcodese \barasciicode        \relax
\letcatcodecommand \xmlcatcodese \tildeasciicode      \relax

\letcatcodecommand \xmlcatcodesr \hashasciicode       \relax
\letcatcodecommand \xmlcatcodesr \dollarasciicode     \relax
\letcatcodecommand \xmlcatcodesr \commentasciicode    \relax
\letcatcodecommand \xmlcatcodesr \backslashasciicode  \relax
\letcatcodecommand \xmlcatcodesr \circumflexasciicode \relax
\letcatcodecommand \xmlcatcodesr \underscoreasciicode \relax
\letcatcodecommand \xmlcatcodesr \leftbraceasciicode  \relax
\letcatcodecommand \xmlcatcodesr \rightbraceasciicode \relax
\letcatcodecommand \xmlcatcodesr \barasciicode        \relax
\letcatcodecommand \xmlcatcodesr \tildeasciicode      \relax

\let\xmlcatcodes   \xmlcatcodesn % beware, in mkiv we use \notcatcodes

%D We register the catcodetables at the \LUA\ end where some further
%D initializations take place.

\ctxcommand{definecatcodetable(
    {\number\xmlcatcodesn,\number\xmlcatcodese,\number\xmlcatcodesr},% letter catcodes
    {\number\xmlcatcodesn,\number\xmlcatcodese,\number\xmlcatcodesr} % activate catcodes
)}

\ctxcommand{registercatcodetable("xmlcatcodes",\number\xmlcatcodes)}

\endinput
