Skip to content
Permalink
Browse files

Resolve bug #72, make sure that inline bindings take precedence over …

…implicitly reading from stdin
  • Loading branch information
ndw committed Feb 11, 2013
1 parent 85aefda commit 6c2893b343236a1c2fd7d4aa8e2d5661f9363df9
@@ -285,7 +285,7 @@ public void run(String[] args) throws SaxonApiException, IOException, URISyntaxE
}
}

if (implicitPort != null) {
if (implicitPort != null && !pipeline.hasReadablePipes(implicitPort)) {
XdmNode doc = runtime.parse(new InputSource(System.in));
pipeline.writeTo(implicitPort, doc);
}
@@ -82,6 +82,18 @@ public XCompoundStep getParent() {
return parent;
}

public boolean hasReadablePipes(String port) {
if (inputs.containsKey(port)) {
return inputs.get(port).size() > 0;
} else {
return false;
}
}

public boolean hasWriteablePipe(String port) {
return outputs.containsKey(port);
}

public RuntimeValue optionAvailable(QName optName) {
if (!inScopeOptions.containsKey(optName)) {
return null;
@@ -8,7 +8,6 @@
import com.xmlcalabash.model.*;

import net.sf.saxon.s9api.SaxonApiException;
import net.sf.saxon.s9api.XdmNode;
import com.xmlcalabash.core.XProcConstants;
import com.xmlcalabash.core.XProcException;
import com.xmlcalabash.core.XProcData;
@@ -2,7 +2,6 @@

import com.xmlcalabash.core.XProcRuntime;
import com.xmlcalabash.core.XProcConstants;
import com.xmlcalabash.core.XProcException;
import com.xmlcalabash.core.XProcData;
import com.xmlcalabash.io.ReadablePipe;
import com.xmlcalabash.io.WritablePipe;
@@ -1,7 +1,6 @@
package com.xmlcalabash.runtime;

import com.xmlcalabash.core.XProcRunnable;
import com.xmlcalabash.core.XProcStep;
import net.sf.saxon.s9api.XdmNode;
import net.sf.saxon.s9api.QName;
import net.sf.saxon.s9api.SaxonApiException;
@@ -31,8 +30,8 @@
protected XProcRuntime runtime = null;
protected Step step = null;
protected String name = null;
private Hashtable<String,XInput> inputs = new Hashtable<String,XInput> ();
private Hashtable<String,XOutput> outputs = new Hashtable<String,XOutput> ();
private Hashtable<String,XInput> xinputs = new Hashtable<String,XInput> ();
private Hashtable<String,XOutput> xoutputs = new Hashtable<String,XOutput> ();
private Hashtable<QName, RuntimeValue> options = new Hashtable<QName, RuntimeValue> ();
private Hashtable<String, Hashtable<QName, RuntimeValue>> parameters = new Hashtable<String, Hashtable<QName, RuntimeValue>> ();
protected XCompoundStep parent = null;
@@ -73,31 +72,31 @@ public XCompoundStep getParent() {

public void addInput(XInput input) {
String port = input.getPort();
if (inputs.containsKey(port)) {
if (xinputs.containsKey(port)) {
throw new XProcException(input.getNode(), "Attempt to add output '" + port + "' port to the same step twice.");
}
inputs.put(port, input);
xinputs.put(port, input);
}

public void addOutput(XOutput output) {
String port = output.getPort();
if (outputs.containsKey(port)) {
if (xoutputs.containsKey(port)) {
throw new XProcException(output.getNode(), "Attempt to add output '" + port + "' port to the same step twice.");
}
outputs.put(port, output);
xoutputs.put(port, output);
}

public XInput getInput(String port) {
if (inputs.containsKey(port)) {
return inputs.get(port);
if (xinputs.containsKey(port)) {
return xinputs.get(port);
} else {
throw new XProcException(step.getNode(), "Attempt to get non-existant input '" + port + "' port from step.");
}
}

public XOutput getOutput(String port) {
if (outputs.containsKey(port)) {
return outputs.get(port);
if (xoutputs.containsKey(port)) {
return xoutputs.get(port);
} else {
if (XProcConstants.NS_XPROC.equals(step.getType().getNamespaceURI())
&& step.getStep().getVersion() > 1.0) {
@@ -13,8 +13,6 @@
import net.sf.saxon.s9api.SaxonApiException;
import net.sf.saxon.s9api.XdmNode;

import java.util.Hashtable;

/**
* Created by IntelliJ IDEA.
* User: ndw

0 comments on commit 6c2893b

Please sign in to comment.
You can’t perform that action at this time.