0
votes

Is it possible to find same-name siblings (SNS) using SQL2, SQL, XPath or QueryBuilder in Adobe CQ5/Adobe Experience Manager. We are trying to prepare the instance for upgrade to AEM 6.X and as already known jackrabbit oak has disabled the support for SNS, which makes the upgrade without solving this problem impossible. The repository could be traversed recursively, but this is too slow and I'm looking for better options using queries. SNS are defined as follows:

/a/b/c
/a/b/c[2]
/a/b/c[3]

/a/b[2]/c[2]
/a/b/c[3]

I would prefer SQL2, but any other option is also possible. Note that no functions or xslt are possible, because we are not talking about xml documents, but for java content repository (JCR).

1
Please be more precise about your requirements. For example, are you looking for the same-name siblings of a specific element, or for all sets of same-name siblings in the whole document?Michael Kay
Thanks for your comment. I'm talking about CQ5/AEM. These tags are also set in the question. This is known problem there, so I didn't saw any need to be more precice as it should be clear enough for people working with the system. Since you clearly didn't understand what exacly the requirements are, I find your comment here and the request to improve ok, but your answer below and your downvote are not appropriate. Thanks anyway for your time!d33t

1 Answers

1
votes

In XQuery 1.0 or XPath 3.0 the same-name siblings of the context node can be found as

let $n := node-name(.)
return (preceding-sibling::* | following-sibling::*)[node-name(.) = $n]

or as

let $n := node-name(.)
return ../*[node-name(.) = $n] except .

(the "except ." can be omitted if you want to include the original element in the result).

I don't think that a pure XPath 1.0 solution is possible, because of the absence of range variables, but with XPath 1.0 within XSLT 1.0 you can do

(preceding-sibling::* | following-sibling::*)
 [local-name(.) = local-name(current()) and 
   namespace-uri(.) = namespace-uri(current())]