use of org.apache.cocoon.sax.util.SAXConsumerAdapter in project syncope by apache.
the class XSLTTransformer method setSAXConsumer.
/**
* {@inheritDoc}
*/
@Override
protected void setSAXConsumer(final SAXConsumer consumer) {
TransformerHandler transformerHandler;
try {
transformerHandler = TRAX_FACTORY.newTransformerHandler(this.templates);
} catch (Exception e) {
throw new SetupException("Could not initialize transformer handler.", e);
}
if (this.parameters != null) {
final Transformer transformer = transformerHandler.getTransformer();
this.parameters.forEach((name, values) -> {
// is valid XSLT parameter name
if (XSLT_PARAMETER_NAME_PATTERN.matcher(name).matches()) {
transformer.setParameter(name, values);
}
});
}
final SAXResult result = new SAXResult();
result.setHandler(consumer);
// According to TrAX specs, all TransformerHandlers are LexicalHandlers
result.setLexicalHandler(consumer);
transformerHandler.setResult(result);
final SAXConsumerAdapter saxConsumerAdapter = new SAXConsumerAdapter();
saxConsumerAdapter.setContentHandler(transformerHandler);
super.setSAXConsumer(saxConsumerAdapter);
}
Aggregations