// Document doc = documentBuilder.parse(resolver.resolveEntity(null, fileIn));
Document doc = documentBuilder.parse(fileIn);
Canonicalizer c14n = Canonicalizer.getInstance(c14nURI);
byte c14nBytes[] = null;
if (xpath == null) {
c14nBytes = c14n.canonicalizeSubtree(doc);
} else {
CachedXPathAPI xpathAPI = new CachedXPathAPI();
NodeList nl = null;
if (xpath instanceof String) {
nl = xpathAPI.selectNodeList(doc, (String) xpath);
} else {
Element xpathElement = (Element) xpath;
String xpathStr = ((Text) xpathElement.getFirstChild()).getData();
nl = xpathAPI.selectNodeList(doc, xpathStr, xpathElement);
}
c14nBytes = c14n.canonicalizeXPathNodeSet(nl);
}
// org.xml.sax.InputSource refIs = resolver.resolveEntity(null, fileRef);
// byte refBytes[] = JavaUtils.getBytesFromStream(refIs.getByteStream());
byte refBytes[] = JavaUtils.getBytesFromFile(fileRef);