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());
}
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;
}
Aggregations