2

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
    \page[yes]
    \dorecurse{3}{
             \bTABLE[frame=on,split=no]
             \xmlflush{#1}
             \eTABLE}
\stopxmlsetups

\startxmlsetups xml:tr
        \bTR
                \xmlflush{#1} 
        \eTR
\stopxmlsetups

\startxmlsetups xml:h2
     \section{\xmlflush{#1}}
\stopxmlsetups


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

Part of the XHTML

                <table class="module">
                    <tr>
                        <th colspan="2">
                            <h2 class="">
                                SECTION</h2>
                        </th>
                    </tr>

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