public ProcessMatch(XProcRuntime runtime, ProcessMatchingNodes processor) { super(runtime); this.runtime = runtime; this.processor = processor; saxonConfig = runtime.getProcessor().getUnderlyingConfiguration(); }
public void error(XdmNode node, String message, QName code) { runtime.error(null, node, message, code); } }
private void loadPipeline(String uri, String id, int seconds) { Calendar expires = GregorianCalendar.getInstance(); if (seconds >= 0) { long millis = seconds; long extime = expires.getTimeInMillis() + (millis*1000); expires.setTimeInMillis(extime); } else { expires.setTimeInMillis(Long.MAX_VALUE); } XProcRuntime runtime = new XProcRuntime(getConfiguration()); try { XdmNode doc = runtime.parse(uri, runtime.getStaticBaseURI().toASCIIString()); XPipeline pipeline = runtime.use(doc); getPipelines().put(id, new PipelineConfiguration(runtime, pipeline, expires)); } catch (Exception e) { throw new XProcException(e); } } }
public StepErrorListener(XProcRuntime runtime) { super(); this.runtime = runtime; this.msgListener = runtime.getMessageListener(); baseURI = runtime.getStaticBaseURI(); }
public XLibrary useLibrary(XdmNode library) throws SaxonApiException { try { return _useLibrary(library); } catch (SaxonApiException sae) { error(sae); throw sae; } catch (XProcException xe) { error(xe); throw xe; } }
public void write(final XdmNode doc) { try { serializer = runtime.getProcessor().newSerializer(); } else { try { DataStore store = runtime.getDataStore(); store.writeEntry(uri, uri, media, new DataWriter() { public void store(OutputStream ostream) throw (SaxonApiException) ex.getCause(); runtime.error(ex); || (System.out.equals(ostream))) && runtime.getDebug()) { System.out.println("\n--<document boundary>--------------------------------------------------------------------------");
runtime = new XProcRuntime(config); pipeline = runtime.load(userArgs.getPipeline()); } else if (userArgs.hasImplicitPipeline()) { XdmNode implicitPipeline = userArgs.getImplicitPipeline(runtime); Serializer serializer = runtime.getProcessor().newSerializer(); pipeline = runtime.use(implicitPipeline); } else if (config.pipeline != null) { XdmNode doc = config.pipeline.read(); pipeline = runtime.use(doc); } else { throw new UnsupportedOperationException("Either a pipeline or libraries and / or steps must be given"); String uri = input.getUri(); if ("-".equals(uri)) { doc = runtime.parse(new InputSource(System.in)); } else { doc = runtime.parse(new InputSource(uri)); InputStream inputStream = input.getInputStream(); try { doc = runtime.parse(new InputSource(inputStream)); } finally { Closer.close(inputStream); XdmNode doc = runtime.parse(new InputSource(System.in)); pipeline.writeTo(implicitPort, doc);
private XdmNode parse(InputStream instream, URI baseURI) throws SaxonApiException { try { XMLReader reader = XMLReaderFactory.createXMLReader(); reader.setEntityResolver(runtime.getResolver()); SAXSource source = new SAXSource(reader, new InputSource(instream)); DocumentBuilder builder = runtime.getProcessor().newDocumentBuilder(); builder.setLineNumbering(true); builder.setDTDValidation(false); builder.setBaseURI(baseURI); return builder.build(source); } catch (SAXException se) { throw new XProcException(se); } }
XdmNode piperoot = S9apiUtils.getDocumentElement(pipedoc); XProcRuntime innerRuntime = new XProcRuntime(runtime); throw new XProcException(step.getNode(), "Step option can only be used when loading a p:library"); pipeline = innerRuntime.use(pipedoc); } else if (XProcConstants.p_library.equals(piperoot.getNodeName())) { XLibrary library = innerRuntime.useLibrary(piperoot); if (stepName == null) { pipeline = library.getFirstPipeline(); innerRuntime.close(); runtime.resetExtensionFunctions();
public void load(URI id, String media, InputStream content, long len) throws IOException { String cs = HttpUtils.getCharset(media); if (cs == null) { cs = Charset.defaultCharset().name(); } InputStreamReader reader = new InputStreamReader(content, cs); JSONTokener jt = new JSONTokener(reader); Processor processor = runtime.getProcessor(); String flavor = runtime.jsonFlavor(); documents.add(JSONtoXML.convert(processor, jt, flavor)); } });
public void runMethod(String[] args) throws IOException, SaxonApiException, URISyntaxException { UserArgs userArgs = new ParseArgs().parse(args); XProcConfiguration config = userArgs.createConfiguration(); runtime = new XProcRuntime(config); debug = config.debug; try { run(userArgs, config); } finally { // Here all memory should be freed by the next gc, right? if (runtime != null) { runtime.close(); } } }
config = mConfig.read(); new ConfigReader(mRuntime.getProcessor(), config, cssExt); mRuntime.info(null, null, uri.toString() + " inlined");
public void run() throws SaxonApiException { logger.trace("Running p:viewport " + step.getName()); XProcData data = runtime.getXProcData(); data.openFrame(this); runtime.getXProcData().setIterationSize(sequenceLength); runtime.start(this); try { XProcMessageListenerHelper.openStep(runtime, this); matcher.match(doc, match); } finally { runtime.getMessageListener().closeStep(); runtime.finish(this);
public void run() throws SaxonApiException { XProcStep xstep = runtime.getConfiguration().newStep(runtime, this); XProcData data = runtime.getXProcData(); data.openFrame(this); runtime.start(this); try { try { throw handleException(e); } finally { runtime.getMessageListener().closeStep(); while (rpipe.moreDocuments()) { XdmNode doc = rpipe.read(); runtime.cache(doc, step.getNode().getBaseURI()); runtime.finish(this); data.closeFrame();
XProcRuntime runtime = new XProcRuntime(getConfiguration()); is.setSystemId(base + "/" + name); XdmNode doc = runtime.parse(is); XPipeline pipeline = runtime.use(doc); getPipelines().put(id, new PipelineConfiguration(runtime, pipeline, expires)); } catch (Exception e) {
if (runtime.getErrorCode() != null) { throw new XProcException(runtime.getErrorCode(), runtime.getErrorMessage()); runtime.start(this); try { XProcMessageListenerHelper.openStep(runtime, this); throw handleException(e); } finally { runtime.getMessageListener().closeStep(); runtime.finish(this);
public PipelineInstance get() { XProcConfiguration config = configFactory.newConfiguration(); XProcRuntime runtime = new XProcRuntime(config); runtime.setMessageListener(new slf4jXProcMessageListener()); if (uriResolver != null) { runtime.setURIResolver(uriResolver); runtime.setEntityResolver(entityResolver); runtime.setMessageListener(listeners); XPipeline xpipeline = null; xpipeline = runtime.load(new com.xmlcalabash.util.Input(uri.toString()));
if (runtime.getConfiguration().foProcessor != null) { foClasses.add(runtime.getConfiguration().foProcessor); } catch (NoClassDefFoundError ncdfe) { logger.debug("No FO processor class available: " + className); if (runtime.getDebug()) { ncdfe.printStackTrace(); DataStore store = runtime.getDataStore(); URI id = store.writeEntry(href, base, contentType, new DataWriter() { public void store(OutputStream content) throws IOException {