Now the only problem that I have is that of providing term highlighting on the xml format. You have suggested using <capture> sql statement capture </capture> then a $ret is available for formatting. Unfortunately the xml schema format is corrupted in that the <,>,and " symbols are converted to <, > , and ". Doing a replace on these would unfortunately remove < and > from the xml data section where it is needed.
Any ideas?
If you're going to be doing query highlighting in Vortex, then you want to display it in Vortex too; it's much easier (and runs faster) to use the normal column variables returned from <SQL> with <fmtcp> for highlighting, than to <SQL output=xml:ado>, capture it, and parse it multiple times for escapement/unescapement and hit markup. In other words, if you're outputting XML data, its receiver is responsible for its display formatting; if it can't do query highlighting and escapement, then let Vortex display it.
If you really need XML output with hit markup and escapement, then print the XML tags directly yourself, with the normal <SQL> column variables (eg. without OUTPUT=xml:ado) so that the XML data can be marked up and escaped as needed.