Obviously this method also relies on you having a method of finding the export skeleton file based on the rig currently being processed.
Getting rid of namespaces can also be handled during this pre-export stage by using the “defaultNamespace” flag when referencing in the export skeleton (although doing this relies on there being no clashing names already existing in the root namespace otherwise objects will be renamed as they are brought in). Then after exporting you can remove the reference and that way it isn’t too destructive to the scene. The way I have dealt with this in the past is to reference in an unrigged version of the character’s export skeleton and connect it to the rigged one (via direct connections to rotate/translate or via constraints if that isn’t possible for some reason) and then export with the FBXExportBakeComplexAnimation flag you mentioned before. It would be pretty useful if they had options in the FBX exporter to strip namespaces and parent transforms but so far I don’t think there is. I’ve had to deal with this in the FBX export pipline also.