Permalink
Browse files

Begin to attempt to address issue #184 by attempting to provide more …

…context for D0006 and D0007 errors
  • Loading branch information...
ndw committed Feb 4, 2015
1 parent 1c10008 commit fff0e91c4242a06edac15fc54127c6a4a0fbd275
@@ -1083,6 +1083,10 @@ public void setReader(Step step) {
// I don't care
}
public void setNames(String stepName, String portName) {
// nop;
}
public void resetReader() {
read = false;
}
@@ -42,6 +42,8 @@
private boolean writeSeqOk = false;
private Step writer = null;
private Step reader = null;
private String stepName = null;
private String portName = null;
/** Creates a new instance of Pipe */
public Pipe(XProcRuntime xproc) {
@@ -66,6 +68,12 @@ public void setWriter(Step step) {
writer = step;
}
// These are for debugging...
public void setNames(String stepName, String portName) {
this.stepName = stepName;
this.portName = portName;
}
public void canWriteSequence(boolean sequence) {
writeSeqOk = sequence;
}
@@ -113,7 +121,7 @@ public DocumentSequence documents() {
public XdmNode read () {
if (pos > 0 && !readSeqOk) {
throw XProcException.dynamicError(6);
dynamicError(6);
}
XdmNode doc = documents.get(pos++);
@@ -134,12 +142,21 @@ public void write(XdmNode doc) {
documents.add(doc);
if (documents.size() > 1 && !writeSeqOk) {
throw XProcException.dynamicError(7);
dynamicError(7);
}
}
public String toString() {
return "[pipe #" + id + "] (" + documents + ")";
}
private void dynamicError(int errno) {
String msg = null;
if (stepName != null) {
msg = "Reading " + portName + " on " + stepName;
}
throw XProcException.dynamicError(errno, (String) msg);
}
}
@@ -263,6 +263,10 @@ public void setReader(Step step) {
reader = step;
}
public void setNames(String stepName, String portName) {
// nop;
}
public boolean moreDocuments() {
DocumentSequence docs = ensureDocuments();
return pos < docs.size();
@@ -103,6 +103,10 @@ public void setReader(Step step) {
reader = step;
}
public void setNames(String stepName, String portName) {
// nop;
}
public boolean moreDocuments() {
if (!readDoc) {
readDoc();
@@ -27,6 +27,10 @@ public void setReader(Step step) {
// nop
}
public void setNames(String stepName, String portName) {
// nop;
}
public void resetReader() {
// nop
}
@@ -121,6 +121,10 @@ public void setReader(Step step) {
reader = step;
}
public void setNames(String stepName, String portName) {
// nop;
}
public XdmNode read() throws SaxonApiException {
XdmNode doc = documents.get(pos++);
@@ -32,6 +32,7 @@
public boolean readSequence();
public XdmNode read() throws SaxonApiException;
public void setReader(Step step);
public void setNames(String stepName, String portName);
public void resetReader();
public boolean moreDocuments();
public boolean closed();
@@ -156,6 +156,10 @@ public void setReader(Step step) {
reader = step;
}
public void setNames(String stepName, String portName) {
// nop;
}
public XdmNode read () throws SaxonApiException {
if (!initialized) {
readSource();
@@ -114,6 +114,7 @@ protected ReadablePipe getPipeFromBinding(Binding binding) {
}
pipe = start.getBinding(pnbinding.getStep(), pnbinding.getPort());
pipe.setNames(pnbinding.getStep(), pnbinding.getPort());
} else if (binding.getBindingType() == Binding.INLINE_BINDING) {
InlineBinding ibinding = (InlineBinding) binding;
pipe = new ReadableInline(runtime, ibinding.nodes(), ibinding.getExcludedNamespaces());
@@ -244,7 +244,7 @@ private void doRun() throws SaxonApiException {
for (ReadablePipe reader : inputs.get(port)) {
// Check for the case where there are no documents, but a sequence is not allowed
if (!reader.moreDocuments() && !pipe.writeSequence()) {
throw XProcException.dynamicError(7);
throw XProcException.dynamicError(7, "Reading " + wport + " on " + name);
}
@@ -200,6 +200,10 @@ public void setReader(Step step) {
reader = step;
}
public void setNames(String stepName, String portName) {
// nop;
}
public XdmNode read () throws SaxonApiException {
if (!initialized) {
readSource();

0 comments on commit fff0e91

Please sign in to comment.