java如何使用jcr XPath在jcr:content/@jcr:data中搜索?
我想在CQ 5.6(AEM)实例中包含的JCR存储库中搜索包含给定字符串.jsp
的所有xxx
文件。由于不熟悉JCR对XPath(或JCR-SQL2)的解释,我在表达查询方面不是很成功
这将获取所有.jsp
文件:
//*[jcr:contains(., '.jsp')]
这就是我希望限制上述包含xxx
的.jsp
文件列表的方式:
//*[jcr:contains(., '.jsp')][jcr:contains(jcr:content/@jcr:data, 'xxx')]
//*[jcr:contains(., '.jsp') and jcr:contains(jcr:content/@jcr:data, 'xxx')]
//*[jcr:contains(., '.jsp')]/jcr:content[jcr:contains(@jcr:data, 'xxx')]/..
@jcr:data
属于Binary
类型。以上这些似乎都不起作用。我哪里做错了
# 1 楼答案
看起来查询应该在nt:file节点上,而不是jcr:data节点上。参见对JCR - Jackrabbit - Xpath expression for search content text of a file contained inside a node的回答
使用querybuilder进行的快速测试显示了来自CQ中JSP文件的结果(在本例中,这些文件包含“/foundation/global.JSP”):
给出: