\startbuffer[test]
<something>
    <a><c>xxxx</c><d>xxxx</d></a>
    <a><c>xxxx</c><d>xxxx</d></a>
    <a><b>1</b><c>xxxx</c><d>xxxx</d></a>
    <a><c>xxxx</c><d>xxxx</d></a>
    <a><c>xxxx</c><d>xxxx</d></a>
    <a><c>xxxx</c><d>xxxx</d></a>
    <a><b>1</b><c>xxxx</c><d>xxxx</d></a>
    <e>eeeeee</e>
    <a><c>xxxx</c><d>xxxx</d></a>
    <a><c>xxxx</c><d>xxxx</d></a>
    <a><c>xxxx</c><d>xxxx</d></a>
    <a><c>xxxx</c><d>xxxx</d></a>
    <e>eeeeee</e>
    <a><c>xxxx</c><d>xxxx</d></a>
    <a><c>xxxx</c><d>xxxx</d></a>
    <a><c>xxxx</c><d>xxxx</d></a>
    <a><c>xxxx</c><d>xxxx</d></a>
</something>
\stopbuffer

\startxmlsetups xml:mysetups
    \xmlsetsetup{#1}{e|something|a}{xml:*}
\stopxmlsetups

\xmlregistersetup{xml:mysetups}

\startxmlsetups xml:something
    \xmlflush{#1}
\stopxmlsetups

\startxmlsetups xml:a
    \disablemode[tabulate-two-columns]
    \disablemode[tabulate-three-columns]
    \xmldoifelse {#1} {/b} {
        \enablemode[tabulate-three-columns]
    } {
        \xmldoifelse {#1} {following-sibling::[quit(name() != 'a')]/b} {
            \enablemode[tabulate-three-columns]
        } {
            \xmldoifelse {#1} {reverse-sibling::[quit(name() != 'a')]/b} {
                \enablemode[tabulate-three-columns]
            } {
                \enablemode[tabulate-two-columns]
            }
        }
    }
    \doifmodeelse {tabulate-three-columns} {
        \starttabulate[|l|l|l|]
            \NC \relax [\xmlfirst{#1}{b}]
            \NC \relax [\xmlfirst{#1}{c}]
            \NC \relax [\xmlfirst{#1}{d}] \NC \NR
        \stoptabulate
    } {
        \starttabulate[|l|l|]
            \NC \relax [\xmlfirst{#1}{c}]
            \NC \relax [\xmlfirst{#1}{d}] \NC \NR
        \stoptabulate
    }
\stopxmlsetups

\startxmlsetups xml:e
    [e:\xmlflush{#1}]
\stopxmlsetups

\starttext
    \xmlprocessbuffer{main}{test}{}
\stoptext
