Write Plugins - Inserting Contextual Metadata values in XML Document

It has come to our attention that variables, and condictions, are resolved in the SDL connected editor (Arbortext, Oxygen) taking into account the publication context when they are checked from Publication Manager rather than an independent instance of the Browse Repository dialog.

 

In an effort to validate writing best practices using Schematron, we are looking to 'inject' some XML code into the document that is being checked out so that tool becomes context aware. It is my understanding that there exists a kind of write plugin that is run when an object is checked out, we are interesting in figuring out a way to use this mechanism for such a purpose -specifically gathering SDL metadata values corresponding to the current context.

Conversely, the context defining code would need to be stripped out at check in time. Could you recommend what's the best approach to implement this feature?

Martin