On 5 Apr 2020, at 12:27, Gerben Wierda
wrote: Alternatively, I could have a step before this to turn the input XML into many separate XMLs and have many ConTeXt runs. Probably that is the best way to do it. Each generated XML would have all of the original XML except it would only have one ‘view’ in it and the rest removed.
Or you could write out a shell script while processing the run. function moduledata.archimate(filename) local root = xml.load(filename) warnIfVerbose( "Processing %s", filename) local shfile = io.open(tex.jobname.. ".sh", "w") local i = 1 for view in xml.collected(root,"diagrams/view") do local viewName = xml.text(view,"/name") shfile:write(string.format('mutool merge -o "%s.pdf" %s "%s.pdf" ', viewName, i, tex.jobname)) i = i + 1 …. end shfile:close() and process that shell script at the end of the run.