Skip to content

Commit

Permalink
Begin to attempt to address issue #184 by attempting to provide more …
Browse files Browse the repository at this point in the history
…context for D0006 and D0007 errors
  • Loading branch information
ndw committed Feb 4, 2015
1 parent 1c10008 commit fff0e91
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/com/xmlcalabash/core/XProcConfiguration.java
Expand Up @@ -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;
}
Expand Down
21 changes: 19 additions & 2 deletions src/com/xmlcalabash/io/Pipe.java
Expand Up @@ -42,6 +42,8 @@ public class Pipe implements ReadablePipe, WritablePipe {
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) {
Expand All @@ -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;
}
Expand Down Expand Up @@ -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++);
Expand All @@ -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);

}
}

4 changes: 4 additions & 0 deletions src/com/xmlcalabash/io/ReadableData.java
Expand Up @@ -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();
Expand Down
4 changes: 4 additions & 0 deletions src/com/xmlcalabash/io/ReadableDocument.java
Expand Up @@ -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();
Expand Down
4 changes: 4 additions & 0 deletions src/com/xmlcalabash/io/ReadableEmpty.java
Expand Up @@ -27,6 +27,10 @@ public void setReader(Step step) {
// nop
}

public void setNames(String stepName, String portName) {
// nop;
}

public void resetReader() {
// nop
}
Expand Down
4 changes: 4 additions & 0 deletions src/com/xmlcalabash/io/ReadableInline.java
Expand Up @@ -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++);

Expand Down
1 change: 1 addition & 0 deletions src/com/xmlcalabash/io/ReadablePipe.java
Expand Up @@ -32,6 +32,7 @@ public interface ReadablePipe {
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();
Expand Down
4 changes: 4 additions & 0 deletions src/com/xmlcalabash/io/Select.java
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/com/xmlcalabash/runtime/XAtomicStep.java
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion src/com/xmlcalabash/runtime/XPipeline.java
Expand Up @@ -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);
}


Expand Down
4 changes: 4 additions & 0 deletions src/com/xmlcalabash/runtime/XSelect.java
Expand Up @@ -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();
Expand Down

0 comments on commit fff0e91

Please sign in to comment.