It all depends on the input.I typically use regex to do this. That is risky and error prone, but it can work quit well. Other people use DCRNode to do it, which can take a while to write. First examine a before and after snapshot of the XML. Decide which approach you want to use. Write your script for a single file, then have it read all files in a folder, finally point it to the correct location for all DCRs.
Use DirWalk,DCRNodes modules....
@jagadeshSecond approach shared by you sounds like more significant here. Can you throw some more light on tuple preprocessor? What are these and how can I implement these.
String path= (String) input.get("path");if(path.matches(CategoryRegex)) //Replace Regex implementation for specific condition matching{ //ex: new field added metadata/author under root if((String)input.get("root/0/metadata/0/author")==null) { input.put("root/0/metadata/0/author","defaulValue"); }}