%%% Makra pro generovani XML vystupu TeXem
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\dil #1 \par{\ifnum\kapnum=0 \else \out {</chapter>}\fi
   \out{^^J<chapter o-num="\the\dilnum" level="1" type="TEXT" o-num-display="YES">#1</chapter>}\kapnum=0 }
\def\oo #1. {}
\def\enddil{}

\def\kap #1 \par{%
    \ifnum\kapnum=0 \else \out {</chapter>^^J}\fi    
    \advance\kapnum by1
    \out{<chapter o-num="\the\kapnum" level="2"
          c-date="2003-09-01" m-date="2003-09-26" type="TEXT"  o-num-display="YES">^^J
      <title>#1</title>}}
\def\okraj #1{\out{ <p-title>#1</p-title>}}
\def\beginpar #1 \par{\out{ \space<p alignment="JUSTIFY">#1</p>}\par}

\def\begtt{\out{ <block type="PRE">}\bgroup 
    \endlinechar=`^^X
    \def\beginpar ##1^^X{\out{ \space<p alignment="LEFT">##1</p>}\par}
}
\def\endtt^^X{\egroup\out{ </block>}}

\def\obr #1[#2]#3{\out{ <illustration><graphic src="#2"/><title>#3</title></illustration>}}

\def\tabnormal #1#2\endtab {\out{ <table popis="#1"><tbody>#2</tbody></table>}}
\def\hline #1 & {^^J \space\space<row><entry>#1</entry>\second}
\def\second#1 \\{<entry>#1</entry></row>}

{\catcode`\%=12 \gdef\%{%}}
{\catcode`\_=12 \gdef\_{_}}
{\catcode`\~=12 \gdef\char`\~{~}}
{\catcode`\&=12 \gdef\ent#1{&#1;}}
\def~{\ent{nbsp}}
\def\,{\ent{thinsp}}
\def\uv#1{\ent{ldquor}#1\ent{rdquor}}

\def\hbox#1{#1}
\def\dots{...}
\def\${$} 
\def\cmd#1{<cmd>#1</cmd>}
\def\bf#1{<b>#1</b>}
\def\it#1{<it>#1</it>}
\def\-{}
\def\TeX{TeX}
\def\/{}

\newwrite\fout
\immediate\openout\fout=ver4out.xml
\def\out{\immediate\write\fout}

\newlinechar=`^^J
\out {<?xml version="1.0" encoding="iso-8859-2"?>}
\out {<!DOCTYPE rwtext SYSTEM "rw-text-xml.dtd">}
\out {<rwtext>}
\out { <rw-meta code="cz_onlinux">}
\out { \space <pub-title>\texttitle</pub-title>}
\out { \space <iss-date day="\the\day" month="\the\month" year="\the\year">%
       \the\day.\the\month.\the\year</iss-date>}
\out { </rw-meta>}
\def\bye {\out{</chapter>^^J</rwtext>}\fin}

\everypar={\beginpar}
\def\plainoutput{\shipout\box255} %% ignorujeme zbytky vystupu do dvi

