\startbuffer[doc]
<?xml version "1.0"?>
<document>
    <section title="First">
        <color>red</color>
        text1
    </section>
    <section title="Second">
        <color>blue</color>
        text2
    </section>
</document>
\stopbuffer

\startluacode
function xml.functions.name(t)
    local content = xml.text(t,"/color")
    context.par() context("function: ") context(content)
end

\stopluacode

\startxmlsetups xml:name
    \xmlsetsetup{\xmldocument}{*}{-}
    \xmlsetsetup{\xmldocument}{document|section}{xml:name:*}
\stopxmlsetups

\xmlregistersetup{xml:name}

\startxmlsetups xml:name:document
    \xmlflush{#1}
\stopxmlsetups

\startxmlsetups xml:name:section
    \startsection[title=\xmlatt{#1}{title}]
    % ctx function
    \xmlfunction{#1}{name}
    % lua only
    \startluacode
        local node = "#1"
        local content = xml.text("#1","/color")
        context.par() context("node: ") context(node)
        context.par() context("lua: ")  context(content)
    \stopluacode
    \stopsection
\stopxmlsetups

\starttext

\xmlprocessbuffer{xml:name}{doc}{}

\stoptext
