1) Readabiltiy
I found some of the source code unreadable...
e.g.
//apply the XSLT to the document
StreamSource result = XSLTTransformer.getInstance().transform(new StreamSource(metalexFile), new StreamSource(xslt));
//apply to the result the XSLT that insert the namespace
StreamSource resultWithNamespace = XSLTTransformer.getInstance().transform(result, new StreamSource(new File(this.akomantosoAddNamespaceXSLTPath)));
I have made it more readable and easier to debug :
//Stream for metalex file
StreamSource ssMetalex = new StreamSource(metalexFile);
//streamsource to xslt that transforms the metalex
StreamSource ssXslt = new StreamSource(xslt);
XSLTTransformer xsltTransformer = XSLTTransformer.getInstance();
//apply the XSLT to the document
StreamSource result = xsltTransformer.transform(ssMetalex, ssXslt);
//stream the AN xslt file
StreamSource ssAnXsltpath = new StreamSource(new File(this.akomantosoAddNamespaceXSLTPath));
//apply to the result the XSLT that insert the namespace
StreamSource resultWithNamespace = xsltTransformer.transform(result, ssAnXsltpath);
2) Object use :
I noticed that whenever you use the XPathResolver / XSLTTransformer / DocmentBuilderFactory clases you use getInstance() or newInstance() even if you are calling them on succesicve lines of code...
e.g. in the below you are creating a new XPathResolver object on every line... is there a reason for this ? why not creat the object once and call its methods successively ?
Node templateContent = (Node)XPathResolver.getInstance().evaluate(XSLTDoc, "//*:template[@match=\"*[@name='" + elementName + "']\"]/*", XPathConstants.NODE);
//get the parent template of the xslt node
Node parentTemplate = (Node)XPathResolver.getInstance().evaluate(pipeline, "//xslt[@href='" + xsltURI + "']/ancestor::*:template", XPathConstants.NODE);
//remove the apply templates node
if((Node)XPathResolver.getInstance().evaluate(pipeline, "//*:template[@match=\"*[@name='" + elementName + "']\"]/*:apply-templates",XPathConstants.NODE) != null)
{
//remove the apply templates node
parentTemplate.removeChild((Node)XPathResolver.getInstance().evaluate(pipeline, "//*:template[@match=\"*[@name='" + elementName + "']\"]/*:apply-templates",XPathConstants.NODE));
}