Permalink
Browse files

Fix issue #171 by checking for a null input document

  • Loading branch information...
ndw committed Aug 21, 2014
1 parent 571e156 commit 475fcd20683823d8fe79636099431c01cb0c9c46
Showing with 13 additions and 3 deletions.
  1. +13 −3 src/com/xmlcalabash/library/Error.java
@@ -65,7 +65,11 @@ public void run() throws SaxonApiException {
super.run();
XdmNode doc = source.read();
finest(null, "Error step " + "???" + " read " + doc.getDocumentURI());
if (doc == null) {
finest(null, "Error step read empty");
} else {
finest(null, "Error step read " + doc.getDocumentURI());
}
RuntimeValue codeNameValue = getOption(_code);
String codeNameStr = codeNameValue.getString();
@@ -103,13 +107,19 @@ public void run() throws SaxonApiException {
treeWriter.addAttribute(_type, "p:error");
treeWriter.addAttribute(_code, errorCode.toString());
treeWriter.startContent();
treeWriter.addSubtree(doc);
if (doc != null) {
treeWriter.addSubtree(doc);
}
treeWriter.addEndElement();
treeWriter.endDocument();
step.reportError(treeWriter.getResult());
throw new XProcException(errorCode, doc, doc.getStringValue());
if (doc == null) {
throw new XProcException(errorCode);
} else {
throw new XProcException(errorCode, doc, doc.getStringValue());
}
}
}

0 comments on commit 475fcd2

Please sign in to comment.