\mainlanguage[cz]
\enableregime[cp1250]

\let\EA\expandafter

\defineXMLenvironment
  [chapterA]
  {\defineXMLsave[title]}
  {\expanded
     {\chapter\XMLflush{title}}}

\defineXMLenvironment
  [chapterB]
  {\defineXMLsave[title]}
  {\EA\EA\EA\EA\EA\EA\EA\chapter\EA\EA\EA\EA\EA\EA\EA{\XMLflush{title}}}

\defineXMLenvironment
  [chapterC]
  {\defineXMLsave[title]}
  {\chapter{\XMLflush{title}}}

\starttext

\startbuffer

<chapterA>
  <title>�lu�ou�c� kon� �p� in toc BAD</title>
</chapterA>

<chapterB>
  <title>�lu�ou�c� kon� �p� in toc GOOD</title>
</chapterB>

<chapterC>
  <title>�lu�ou�c� kon� �p� in toc BAD</title>
</chapterC>

\stopbuffer

\processXMLbuffer

\completecontent[criterium=all]

\stoptext
