Fix search in mounted DOM content provider
authorMathieu Baudier <mbaudier@argeo.org>
Thu, 22 Feb 2024 09:16:50 +0000 (10:16 +0100)
committerMathieu Baudier <mbaudier@argeo.org>
Thu, 22 Feb 2024 09:16:50 +0000 (10:16 +0100)
org.argeo.cms/src/org/argeo/cms/acr/xml/DomContentProvider.java

index 845a6ab4c22a23629194b6bab0e3a0609d8ed2d9..20f7eb1534cbb79fb21bd17e0fe93585e17bb706 100644 (file)
@@ -75,9 +75,13 @@ public class DomContentProvider implements ContentProvider, NamespaceContext {
        protected NodeList findContent(String relativePath) {
                if (relativePath.startsWith("/"))
                        throw new IllegalArgumentException("Relative path cannot start with /");
-               String xPathExpression = '/' + relativePath;
-               if (Content.ROOT_PATH.equals(mountPath)) // repository root
-                       xPathExpression = "/" + CrName.root.get() + xPathExpression;
+               String xPathExpression;
+               if (Content.ROOT_PATH.equals(mountPath)) {// repository root
+                       xPathExpression = "/" + CrName.root.get() + '/' + relativePath;
+               } else {
+                       String documentNodeName = document.getDocumentElement().getNodeName();
+                       xPathExpression = '/' + documentNodeName + '/' + relativePath;
+               }
                try {
                        NodeList nodes = (NodeList) xPath.get().evaluate(xPathExpression, document, XPathConstants.NODESET);
                        return nodes;