I would like to use the header of a table as a section for the TOC (while parsing an XML to pdf)

\startxmlsetups xml:table

\startxmlsetups xml:tr

\startxmlsetups xml:h2

\startxmlsetups xml:th
\doifnumberelse {\xmlatt{#1}{colspan}}
            {\bTD [nc=\xmlatt{#1}{colspan},background=color,backgroundcolor=UniGelb] 

Part of the XHTML

                <table class="module">
                        <th colspan="2">
                            <h2 class="">

The Problem: The section part gets flushed 3 times so the TOC is broken and the numbers are wrong:

structure       > sectioning > section @ level 3 : 0.0.1 -> \xmlflush {main::9}
structure       > sectioning > section @ level 3 : 0.0.2 -> \xmlflush {main::9}
structure       > sectioning > section @ level 3 : 0.0.3 -> \xmlflush {main::9}

Result: Broken TOC with Section "3 Section" instead of "1 Section"

  • Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See minimal working example (MWE). – Henri Menke Jul 12 '17 at 5:47