public void configure(final JSONObject config) throws PluginBuildException { if (null == config) { throw new PluginBuildException("Cannot build plugin with null configuration"); } String xsltUrl = config.getString("stylesheet_url"); InputStream content; try { URLConnection connection = new URL(xsltUrl).openConnection(); connection.connect(); content = (InputStream) connection.getContent(); } catch (IOException e) { log.fatal(e); String msg = "Unable to read stylesheet"; notifier.notify(NotificationType.Unavailable, msg + ": " + e.getMessage()); throw new PluginBuildException(msg + ".", e); } StreamSource xsltSource = new StreamSource(content); TransformerFactory factory = TransformerFactory.newInstance(); factory.setErrorListener(xsltErrorLogger); Transformer temp; try { temp = factory.newTransformer(xsltSource); } catch (TransformerConfigurationException e) { log.fatal(e); String msg = "Cannot compile configured stylesheet"; notifier.notify(NotificationType.FatalError, msg + ":" + e.getMessage()); throw new PluginBuildException(msg, e); } transformer = temp; transformer.setErrorListener(xsltErrorLogger); registerInput("input", input); }
public void setErrorListener(ErrorListener listener) throws IllegalArgumentException { transformer.setErrorListener(listener); }