Permalink
Browse files

Attempt to handle missing/empty href as same-document reference

  • Loading branch information...
ndw committed Apr 15, 2016
1 parent 206d518 commit b0ebaf0915b7c6f00b56b9830bcfad2efa86bd6f
Showing with 17 additions and 9 deletions.
  1. +17 −9 src/main/java/com/xmlcalabash/library/XInclude.java
@@ -254,7 +254,7 @@ public boolean processStartElement(XdmNode node) throws SaxonApiException {
} else {
setXmlId.push(setId);
subdoc = readXML(href, node.getBaseURI().toASCIIString());
subdoc = readXML(node, href, node.getBaseURI().toASCIIString());
String iuri = null;
@@ -412,16 +412,24 @@ String readText(final XdmNode node, final XPointer xpointer, String media,
}
}
public XdmNode readXML(String href, String base) {
public XdmNode readXML(XdmNode node, String href, String base) {
logger.trace("XInclude read XML: " + href + " (" + base + ")");
try {
XdmNode doc = runtime.parse(href, base);
return doc;
} catch (Exception e) {
logger.debug("XInclude read XML failed");
mostRecentException = e;
return null;
if (href == null || "".equals(href)) {
XdmNode ptr = node;
while (ptr.getParent() != null) {
ptr = ptr.getParent();
}
return ptr;
} else {
try {
XdmNode doc = runtime.parse(href, base);
return doc;
} catch (Exception e) {
logger.debug("XInclude read XML failed");
mostRecentException = e;
return null;
}
}
}

0 comments on commit b0ebaf0

Please sign in to comment.