use of org.apache.synapse.util.resolver.CustomJAXPURIResolver in project wso2-synapse by wso2.
the class XSLTMediator method createTemplate.
/**
* Create a XSLT template object and assign it to the cachedTemplates variable
* @param synCtx current message
* @param synLog logger to use
* @param generatedXsltKey evaluated xslt key(real key value) for dynamic or static key
* @return cached template
*/
private Templates createTemplate(MessageContext synCtx, SynapseLog synLog, String generatedXsltKey) {
// Assign created template
Templates cachedTemplates = null;
// Set an error listener (SYNAPSE-307).
transFact.setErrorListener(new ErrorListenerImpl(synLog, STYLESHEET_PARSING_ACTIVITY));
// Allow xsl:import and xsl:include resolution
transFact.setURIResolver(new CustomJAXPURIResolver(resourceMap, synCtx.getConfiguration(), synCtx));
try {
cachedTemplates = transFact.newTemplates(SynapseConfigUtils.getStreamSource(synCtx.getEntry(generatedXsltKey)));
if (cachedTemplates == null) {
// if cached template creation failed
handleException("Error compiling the XSLT with key : " + xsltKey, synCtx);
} else {
if (useCache) {
// if cached template is created then put it in to cachedTemplatesMap
cachedTemplatesMap.put(generatedXsltKey, cachedTemplates);
}
}
} catch (Exception e) {
handleException("Error creating XSLT transformer using : " + xsltKey, e, synCtx);
}
return cachedTemplates;
}
Aggregations