In Java, from TransformerFactory to create objects for processing XSLT, and it has methods:
newTransformer , which creates a Transformer object that can transform the XML into a result.newTemplates , which creates a Templates object that Transformer can create.
The documentation for Transformer explicitly states:
The transformer can be used several times.
My application processes various XML files with the same XSLT. At the beginning of the program, I use newTransformer to create a Transformer , and then reuse it for all XML files (make sure it is synchronized, so I use it from only one thread and calling its reset() method before each processing.).
Thus, I do not incur the cost of recompiling XSLT for each XML I process.
So what is the point of the newTemplates and Templates object? Should I use this instead and create a new Transformer object for each XML?
java xml xslt saxon
Adrian smith
source share