使用 XPATH 在 CQ 中进行日期范围比较

Date range comparison in CQ using XPATH

我正在使用以下查询根据 CQ 中的最后修改日期获取节点。

/jcr:root/content/scaffoldes/properties//*[@jcr:primaryType = 'nt:unstructured' and (@sling:resourceType = 'acme/components/content/scaffoldItem' or @sling:resourceType = 'acme-core/components/data/property') and @jcr:content/cq:lastModified >= xs:dateTime('2000-01-01T00:00:00.000-08:00') and @jcr:content/cq:lastModified < xs:dateTime('2014-12-31T00:00:00.000-08:00') and not(@isHidden)] order by @jcr:score

我们用过

  http://localhost:4502/crx/explorer/ui/search.jsp

测试这个查询。但是,即使给出了一个很大的日期范围(2000 - 2016),这个查询也没有返回任何内容。

但是如果我们删除日期范围部分,这个查询 returns 个节点。

任何纠正此问题的指示都会有所帮助。

感谢和问候, 三

备注

日期字符串是使用以下代码创建的:

Calendar cal = Calendar.getInstance();
cal.setTime(start);
String startDate = ValueFactoryImpl.getInstance().createValue(cal).getString();

对于造成的任何混乱,我们深表歉意。我发现我要查询的节点没有 cq:lastModified 属性。因此修改查询以在条件中包含 cq:lastReplicated。

 ... and ((@jcr:content/cq:lastModified >= xs:dateTime('2000-01-01T00:00:00.000-08:00') and @jcr:content/cq:lastModified < xs:dateTime('2016-02-11T15:52:57.090-08:00')) or (@jcr:content/cq:lastReplicated >= xs:dateTime('2000-01-01T00:00:00.000-08:00') and @jcr:content/cq:lastReplicated < xs:dateTime('2016-02-11T15:52:57.090-08:00'))) and ...