public Source resolve(String href, String base) throws TransformerException { if ("iso_schematron_skeleton_for_saxon.xsl".equals(href)) { return new SAXSource(new InputSource(skeleton)); } else { throw new XProcException(step.getNode(), "Failed to resolve " + href + " from JAR file."); } } }
public void run(String addnLog) { String type = null; if (XProcConstants.NS_XPROC.equals(step.getType().getNamespaceURI())) { type = step.getType().getLocalName(); } else { type = step.getType().getClarkName(); } logger.debug("Running " + type + " " + step.getName() + addnLog); String msg = step.getExtensionAttribute(cx_message); if (msg != null) { System.err.println("Message: " + msg); } }
public void reset() { for (String port : inputs.keySet()) { for (ReadablePipe rpipe : inputs.get(port)) { rpipe.resetReader(); } } for (String port : outputs.keySet()) { WritablePipe wpipe = outputs.get(port); wpipe.resetWriter(); } clearOptions(); clearParameters(); }
public void run() throws SaxonApiException { super.run(); HashSet<String> excludeUris = S9apiUtils.excludeInlinePrefixes(step.getNode(), getOption(_prefixes).getString()); while (source.moreDocuments()) { XdmNode doc = source.read(); logger.trace(MessageFormatter.nodeMessage(step.getNode(), "Namespace-delete step " + step.getName() + " read " + doc.getDocumentURI())); doc = S9apiUtils.removeNamespaces(runtime, doc, excludeUris, false); result.write(doc); } } }
public void message(XdmNode content, boolean terminate, javax.xml.transform.SourceLocator locator) { if (runtime.getShowMessages()) { System.err.println(content.toString()); } TreeWriter treeWriter = new TreeWriter(runtime); treeWriter.startDocument(content.getBaseURI()); treeWriter.addStartElement(XProcConstants.c_error); treeWriter.startContent(); treeWriter.addSubtree(content); treeWriter.addEndElement(); treeWriter.endDocument(); step.reportError(treeWriter.getResult()); step.info(step.getNode(), content.toString()); } }
public DefaultStep(XProcRuntime runtime, XAtomicStep step) { this.runtime = runtime; this.step = step; Class impl = runtime.getConfiguration().implementations.get(step.getType()); if (impl == null) { // We're headed for a world of hurt... logger = LoggerFactory.getLogger(DefaultStep.class); } else { logger = LoggerFactory.getLogger(impl); } }
public void instantiate(Step step) { instantiateReaders(step); for (Output output : step.outputs()) { String port = output.getPort(); XOutput xoutput = new XOutput(runtime, output); xoutput.setLogger(step.getLog(port)); addOutput(xoutput); WritablePipe wpipe = xoutput.getWriter(); wpipe.canWriteSequence(output.getSequence()); outputs.put(port, wpipe); logger.trace(MessageFormatter.nodeMessage(step.getNode(), step.getName() + " writes to " + wpipe + " for " + port)); } parent.addStep(this); }
protected void instantiateReaders(Step step) { for (Input input : step.inputs()) { String port = input.getPort(); if (!port.startsWith("|")) { Vector<ReadablePipe> readers = null; if (inputs.containsKey(port)) { readers = inputs.get(port); } else { readers = new Vector<ReadablePipe> (); inputs.put(port, readers); } for (Binding binding : input.getBinding()) { ReadablePipe pipe = getPipeFromBinding(binding); pipe.canReadSequence(input.getSequence()); if (input.getSelect() != null) { logger.trace(MessageFormatter.nodeMessage(step.getNode(), step.getName() + " selects from " + pipe + " for " + port)); pipe = new XSelect(runtime, this, pipe, input.getSelect(), input.getNode()); } readers.add(pipe); logger.trace(MessageFormatter.nodeMessage(step.getNode(), step.getName() + " reads from " + pipe + " for " + port)); } XInput xinput = new XInput(runtime, input); addInput(xinput); } } }
XAtomicStep newstep = new XAtomicStep(runtime, substep, this); newstep.instantiate(substep);
public void run() throws SaxonApiException { super.run(); HashSet<String> excludeUris = S9apiUtils.excludeInlinePrefixes(step.getNode(), getOption(_prefixes).getString()); while (source.moreDocuments()) { XdmNode doc = source.read(); logger.trace(MessageFormatter.nodeMessage(step.getNode(), "Namespace-delete step " + step.getName() + " read " + doc.getDocumentURI())); doc = S9apiUtils.removeNamespaces(runtime, doc, excludeUris, false); result.write(doc); } } }
public void message(XdmNode content, boolean terminate, SourceLocator locator) { if (runtime.getShowMessages()) { System.err.println(content.toString()); } TreeWriter treeWriter = new TreeWriter(runtime); treeWriter.startDocument(content.getBaseURI()); treeWriter.addStartElement(XProcConstants.c_error); treeWriter.startContent(); treeWriter.addSubtree(content); treeWriter.addEndElement(); treeWriter.endDocument(); step.reportError(treeWriter.getResult()); if (!terminate) step.info(step.getNode(), content.toString()); if (terminate) terminatingMessage = content; }
public DefaultStep(XProcRuntime runtime, XAtomicStep step) { this.runtime = runtime; this.step = step; Class impl = runtime.getConfiguration().implementations.get(step.getType()); if (impl == null) { // We're headed for a world of hurt... logger = LoggerFactory.getLogger(DefaultStep.class); } else { logger = LoggerFactory.getLogger(impl); } }
public void instantiate(Step step) { instantiateReaders(step); for (Output output : step.outputs()) { String port = output.getPort(); XOutput xoutput = new XOutput(runtime, output); xoutput.setLogger(step.getLog(port)); addOutput(xoutput); WritablePipe wpipe = xoutput.getWriter(); wpipe.canWriteSequence(output.getSequence()); outputs.put(port, wpipe); logger.trace(MessageFormatter.nodeMessage(step.getNode(), step.getName() + " writes to " + wpipe + " for " + port)); } parent.addStep(this); }
protected void instantiateReaders(Step step) { for (Input input : step.inputs()) { String port = input.getPort(); if (!port.startsWith("|")) { Vector<ReadablePipe> readers = null; if (inputs.containsKey(port)) { readers = inputs.get(port); } else { readers = new Vector<ReadablePipe> (); inputs.put(port, readers); } for (Binding binding : input.getBinding()) { ReadablePipe pipe = getPipeFromBinding(binding); pipe.canReadSequence(input.getSequence()); if (input.getSelect() != null) { logger.trace(MessageFormatter.nodeMessage(step.getNode(), step.getName() + " selects from " + pipe + " for " + port)); pipe = new XSelect(runtime, this, pipe, input.getSelect(), input.getNode()); } readers.add(pipe); logger.trace(MessageFormatter.nodeMessage(step.getNode(), step.getName() + " reads from " + pipe + " for " + port)); } XInput xinput = new XInput(runtime, input); addInput(xinput); } } }
XAtomicStep newstep = new XAtomicStep(runtime, substep, this); newstep.instantiate(substep);
public Source resolve(String href, String base) throws TransformerException { if ("iso_schematron_skeleton_for_saxon.xsl".equals(href)) { return new SAXSource(new InputSource(skeleton)); } else { throw new XProcException(step.getNode(), "Failed to resolve " + href + " from JAR file."); } } }
public void run(String addnLog) { String type = null; if (XProcConstants.NS_XPROC.equals(step.getType().getNamespaceURI())) { type = step.getType().getLocalName(); } else { type = step.getType().getClarkName(); } logger.debug("Running " + type + " " + step.getName() + addnLog); String msg = step.getExtensionAttribute(cx_message); if (msg != null) { System.err.println("Message: " + msg); } }
public XProcStep newStep(XProcRuntime runtime,XAtomicStep step){ Class<?> klass = implementations.get(step.getType()); if (klass == null) { throw new XProcException("Misconfigured. No 'class' in configuration for " + step.getType()); } String className = klass.getName(); // FIXME: This isn't really very secure... if (runtime.getSafeMode() && !className.startsWith("com.xmlcalabash.")) { throw XProcException.dynamicError(21); } try { Constructor<? extends XProcStep> constructor = Class.forName(className).asSubclass(XProcStep.class).getConstructor(XProcRuntime.class, XAtomicStep.class); return constructor.newInstance(runtime,step); } catch (NoSuchMethodException nsme) { throw new UnsupportedOperationException("No such method: " + className, nsme); } catch (ClassNotFoundException cfne) { throw new UnsupportedOperationException("Class not found: " + className, cfne); } catch (InstantiationException ie) { throw new UnsupportedOperationException("Instantiation error", ie); } catch (IllegalAccessException iae) { throw new UnsupportedOperationException("Illegal access error", iae); } catch (InvocationTargetException ite) { throw new UnsupportedOperationException("Invocation target exception", ite); } }
public void reset() { for (String port : inputs.keySet()) { for (ReadablePipe rpipe : inputs.get(port)) { rpipe.resetReader(); } } for (String port : outputs.keySet()) { WritablePipe wpipe = outputs.get(port); wpipe.resetWriter(); } clearOptions(); clearParameters(); }