+ String xPathExpression = '/' + relativePath;
+ if ("/".equals(mountPath))
+ xPathExpression = "/cr:root" + xPathExpression;
+ try {
+ NodeList nodes = (NodeList) xPath.get().evaluate(xPathExpression, document, XPathConstants.NODESET);
+ if (nodes.getLength() > 1)
+ throw new IllegalArgumentException(
+ "Multiple content found for " + relativePath + " under " + mountPath);
+ if (nodes.getLength() == 0)
+ throw new ContentNotFoundException("Path " + relativePath + " under " + mountPath + " was not found");
+ Element element = (Element) nodes.item(0);
+ return new DomContent(session, this, element);
+ } catch (XPathExpressionException e) {
+ throw new IllegalArgumentException("XPath expression " + xPathExpression + " cannot be evaluated", e);
+ }