Maybe this is of some use. The Lua code in the file checks the xml and returns info when something is wrong.
% Prerun an xml check.
\doifinset{\xmlatt{#1}{checkxml}}{yes,on,true}%
{\xmlcommand{#1}{.}{xmlcommon:checkxml}}
% Execute this code if no error was found.
etc.