One more observation on the strangeness of \setuppagenumber.
Putting \setuppagenumber[number=4]
before the call to \xmlprocessbuffer
and putting \setuppagenumber[state=stop,number=8]
inside the \startxmlsetups does make the pagenumber having the value 8.
This proves two things:
(1) the \setuppagenumber in
the \startxmlsetups is processed before the pagenumber is fixed
and typeset
(2) the [state=stop] in the \startxmlsetups is wrongfully ignored, whereas at the same time
[number=8] does get honored.
Imho this demonstrates there
is an error in the processing of \setuppagenumber when located inside
the \startxmlsetups. An error
that does not occur when called at the \starttext document-level before
the \xmlprocessbuffer.
Could it be a matter of
locality?