\startbuffer[test]
<something>
    <e>eeeeee</e>
    <a><c>xxxx1</c><d>xxxx1</d></a>
    <a><c>xxxx2</c><d>xxxx2</d></a>
    <a><b>1</b><c>xxxx3</c><d>xxxx3</d></a>
    <a><c>xxxx4</c><d>xxxx4</d></a>
    <a><c>xxxx5</c><d>xxxx5</d></a>
    <a><c>xxxx6</c><d>xxxx6</d></a>
    <a><b>1</b><c>xxxx7</c><d>xxxx7</d></a>
    <e>eeeeee</e>
    <a><c>xxxx1</c><d>xxxx1</d></a>
    <a><c>xxxx2</c><d>xxxx2</d></a>
    <a><c>xxxx3</c><d>xxxx3</d></a>
    <a><c>xxxx4</c><d>xxxx4</d></a>
    <e>eeeeee</e>
    <a><c>xxxx1</c><d>xxxx1</d></a>
    <a><c>xxxx2</c><d>xxxx2</d></a>
    <a><c>xxxx3</c><d>xxxx3</d></a>
    <a><c>xxxx4</c><d>xxxx4</d></a>
    <e>eeeeee</e>
    <a><b>1</b><c>xxxx7</c><d>xxxx7</d></a>
    <a><b>1</b><c>xxxx7</c><d>xxxx7</d></a>
    <a><b>1</b><c>xxxx7</c><d>xxxx7</d></a>
</something>
\stopbuffer

\startxmlsetups xml:mysetups
    \xmlsetsetup{#1}{e|something|a}{xml:*}
    \xmlsetsetup{#1}{a[name(-1) != 'a']}{xml:aa}
\stopxmlsetups

\xmlregistersetup{xml:mysetups}

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

\startluacode
    function xml.functions.make_tabulate(e)
        -- 'e' is the first a in a sequence
        local p = e.__p__
        local dt = p.dt
        local el = { }
        for i=e.ni,#dt do
            local ei = dt[i]
            if type(ei) == "table" then
                if ei.tg == "a" then
                    el[#el+1] = ei
                else
                    break
                end
            end
        end
        local three = false
        for i=1,#el do
            if xml.filter(el[i],"/b") then
                three = true
                break
            end
        end
        if three then
            context.starttabulate { "||||" }
        else
            context.starttabulate { "|||" }
        end
        for i=1,#el do
            local e = el[i]
            context.NC()
            if three then
                xml.cprint(xml.first(e,"/b"))
                context.NC()
            end
            xml.cprint(xml.first(e,"/c"))
            context.NC()
            xml.cprint(xml.first(e,"/d"))
            context.NC()
            context.NR()
        end
        context.stoptabulate()
    end
\stopluacode

\startxmlsetups xml:aa
    \xmlfunction{#1}{make_tabulate}
\stopxmlsetups

% \startxmlsetups xml:a
%     \xmlflush{#1}
% \stopxmlsetups

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

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