Search in sources :

Example 1 with TraceManager

use of org.apache.xalan.trace.TraceManager in project webtools.sourceediting by eclipse.

the class XalanDebugger method addTransformer.

public void addTransformer(Transformer transformer) {
    TransformerImpl transformerImpl = (TransformerImpl) transformer;
    lastTransformerInChain = transformerImpl;
    TraceManager trMgr = transformerImpl.getTraceManager();
    try {
        // XalanPrintTraceListener printer = new XalanPrintTraceListener(new PrintWriter(System.err));
        // printer.m_traceElements = true;
        // printer.m_traceSelection = true;
        // printer.m_traceTemplates = true;
        // trMgr.addTraceListener(printer);
        XalanTraceListener traceListener = new XalanTraceListener(this);
        trMgr.addTraceListener(traceListener);
    } catch (TooManyListenersException e) {
    // ignore
    }
}
Also used : TransformerImpl(org.apache.xalan.transformer.TransformerImpl) TooManyListenersException(java.util.TooManyListenersException) TraceManager(org.apache.xalan.trace.TraceManager)

Example 2 with TraceManager

use of org.apache.xalan.trace.TraceManager in project mycore by MyCoRe-Org.

the class MCRTemplatesCompiler method getTransformer.

/**
 * Returns a new transformer for the compiled XSL templates
 */
public static Transformer getTransformer(Templates templates) throws TransformerConfigurationException {
    Transformer tf = factory.newTransformerHandler(templates).getTransformer();
    // In debug mode, add a TraceListener to log stylesheet execution
    if (LOGGER.isDebugEnabled()) {
        try {
            TraceManager tm = ((org.apache.xalan.transformer.TransformerImpl) tf).getTraceManager();
            tm.addTraceListener(new MCRTraceListener());
        } catch (Exception ex) {
            LOGGER.warn(ex);
        }
    }
    return tf;
}
Also used : Transformer(javax.xml.transform.Transformer) TraceManager(org.apache.xalan.trace.TraceManager) WrappedRuntimeException(org.apache.xml.utils.WrappedRuntimeException) TransformerException(javax.xml.transform.TransformerException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) MCRConfigurationException(org.mycore.common.config.MCRConfigurationException)

Example 3 with TraceManager

use of org.apache.xalan.trace.TraceManager in project mycore by MyCoRe-Org.

the class MCRXSLTransformer method getTransformHandlerList.

protected LinkedList<TransformerHandler> getTransformHandlerList(MCRParameterCollector parameterCollector) throws TransformerConfigurationException, SAXException, ParserConfigurationException {
    checkTemplateUptodate();
    LinkedList<TransformerHandler> xslSteps = new LinkedList<>();
    // every transformhandler shares the same ErrorListener instance
    MCRErrorListener errorListener = MCRErrorListener.getInstance();
    for (Templates template : templates) {
        TransformerHandler handler = tFactory.newTransformerHandler(template);
        parameterCollector.setParametersTo(handler.getTransformer());
        handler.getTransformer().setErrorListener(errorListener);
        if (TRACE_LISTENER_ENABLED) {
            TransformerImpl transformer = (TransformerImpl) handler.getTransformer();
            TraceManager traceManager = transformer.getTraceManager();
            try {
                traceManager.addTraceListener(TRACE_LISTENER);
            } catch (TooManyListenersException e) {
                LOGGER.warn("Could not add MCRTraceListener.", e);
            }
        }
        if (!xslSteps.isEmpty()) {
            Result result = new SAXResult(handler);
            xslSteps.getLast().setResult(result);
        }
        xslSteps.add(handler);
    }
    return xslSteps;
}
Also used : TransformerImpl(org.apache.xalan.transformer.TransformerImpl) TransformerHandler(javax.xml.transform.sax.TransformerHandler) TooManyListenersException(java.util.TooManyListenersException) MCRErrorListener(org.mycore.common.xsl.MCRErrorListener) SAXResult(javax.xml.transform.sax.SAXResult) Templates(javax.xml.transform.Templates) TraceManager(org.apache.xalan.trace.TraceManager) LinkedList(java.util.LinkedList) StreamResult(javax.xml.transform.stream.StreamResult) Result(javax.xml.transform.Result) SAXResult(javax.xml.transform.sax.SAXResult)

Aggregations

TraceManager (org.apache.xalan.trace.TraceManager)3 TooManyListenersException (java.util.TooManyListenersException)2 TransformerImpl (org.apache.xalan.transformer.TransformerImpl)2 LinkedList (java.util.LinkedList)1 Result (javax.xml.transform.Result)1 Templates (javax.xml.transform.Templates)1 Transformer (javax.xml.transform.Transformer)1 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)1 TransformerException (javax.xml.transform.TransformerException)1 SAXResult (javax.xml.transform.sax.SAXResult)1 TransformerHandler (javax.xml.transform.sax.TransformerHandler)1 StreamResult (javax.xml.transform.stream.StreamResult)1 WrappedRuntimeException (org.apache.xml.utils.WrappedRuntimeException)1 MCRConfigurationException (org.mycore.common.config.MCRConfigurationException)1 MCRErrorListener (org.mycore.common.xsl.MCRErrorListener)1