Search in sources :

Example 11 with TransformerImpl

use of org.apache.xalan.transformer.TransformerImpl in project nokogiri by sparklemotion.

the class XsltStylesheet method serialize.

@JRubyMethod
public IRubyObject serialize(ThreadContext context, IRubyObject doc) throws IOException, TransformerException {
    XmlDocument xmlDoc = (XmlDocument) doc;
    TransformerImpl transformer = (TransformerImpl) this.sheet.newTransformer();
    ByteArrayOutputStream writer = new ByteArrayOutputStream();
    StreamResult streamResult = new StreamResult(writer);
    SerializationHandler serializationHandler = transformer.createSerializationHandler(streamResult);
    serializationHandler.serialize(xmlDoc.getNode());
    return context.getRuntime().newString(writer.toString());
}
Also used : TransformerImpl(org.apache.xalan.transformer.TransformerImpl) StreamResult(javax.xml.transform.stream.StreamResult) SerializationHandler(org.apache.xml.serializer.SerializationHandler) ByteArrayOutputStream(java.io.ByteArrayOutputStream) JRubyMethod(org.jruby.anno.JRubyMethod)

Example 12 with TransformerImpl

use of org.apache.xalan.transformer.TransformerImpl in project intellij-community by JetBrains.

the class XalanSupport method init.

public static boolean init(Transformer transformer, LocalDebugger dbg) {
    if (transformer instanceof TransformerImpl) {
        try {
            System.out.println("XALAN: " + Class.forName("org.apache.xalan.Version", true, transformer.getClass().getClassLoader()).getMethod("getVersion").invoke(null));
            final TransformerImpl tr = (TransformerImpl) transformer;
            tr.setErrorListener(new DefaultErrorHandler(false) {

                @Override
                public void fatalError(TransformerException exception) throws TransformerException {
                    if (!(exception.getCause() instanceof DebuggerStoppedException)) {
                        super.fatalError(exception);
                    }
                }
            });
            try {
                tr.getTraceManager().addTraceListener(new XalanTraceListener(dbg, tr));
            } catch (TooManyListenersException e) {
                throw new AssertionError(e);
            }
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return false;
}
Also used : TransformerImpl(org.apache.xalan.transformer.TransformerImpl) TooManyListenersException(java.util.TooManyListenersException) DefaultErrorHandler(org.apache.xml.utils.DefaultErrorHandler) TransformerException(javax.xml.transform.TransformerException) TooManyListenersException(java.util.TooManyListenersException) TransformerException(javax.xml.transform.TransformerException) DebuggerStoppedException(org.intellij.plugins.xsltDebugger.rt.engine.DebuggerStoppedException) DebuggerStoppedException(org.intellij.plugins.xsltDebugger.rt.engine.DebuggerStoppedException)

Aggregations

TransformerImpl (org.apache.xalan.transformer.TransformerImpl)12 DTM (org.apache.xml.dtm.DTM)6 QName (org.apache.xml.utils.QName)4 TransformerException (javax.xml.transform.TransformerException)3 Hashtable (java.util.Hashtable)2 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)2 TransformerHandler (javax.xml.transform.sax.TransformerHandler)2 KeyManager (org.apache.xalan.transformer.KeyManager)2 DTMIterator (org.apache.xml.dtm.DTMIterator)2 XMLString (org.apache.xml.utils.XMLString)2 ExtensionsProvider (org.apache.xpath.ExtensionsProvider)2 UnionPathIterator (org.apache.xpath.axes.UnionPathIterator)2 XNodeSet (org.apache.xpath.objects.XNodeSet)2 XObject (org.apache.xpath.objects.XObject)2 SAXException (org.xml.sax.SAXException)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 TooManyListenersException (java.util.TooManyListenersException)1 StreamResult (javax.xml.transform.stream.StreamResult)1 SerializationHandler (org.apache.xml.serializer.SerializationHandler)1 DefaultErrorHandler (org.apache.xml.utils.DefaultErrorHandler)1