0

是否存在SQL2与以下查询相同的XPath查询:

/jcr:root/content/ancestor//parent/jcr:content

它应该返回以下节点,例如:

/content/ancestor/a/b/c/parent/jcr:content
/content/ancestor/a/parent/jcr:content
/content/ancestor/parent/jcr:content

但不是以下节点:

/content/xxx/a/b/c/parent/jcr:content
/content/xxx/a/parent/jcr:content
/content/xxx/parent/jcr:content
4

2 回答 2

1

以下应该工作:

SELECT * FROM [nt:base] AS s 
  INNER JOIN [nt:base] AS parent
    ON ISCHILDNODE(s, parent)
WHERE
  ISDESCENDANTNODE(s, [/content/ancestor]) AND
  NAME(parent) = 'parent' AND
  NAME(s) = 'jcr:content'

如果 is 的类型和isscq:PageContent类型,您可以使用此信息来加快查询速度:parentcq:Page

SELECT * FROM [cq:PageContent] AS s 
  INNER JOIN [cq:Page] AS parent
    ON ISCHILDNODE(s, parent)
WHERE
  ISDESCENDANTNODE(s, [/content/ancestor]) AND
  NAME(parent) = 'parent' AND
  NAME(s) = 'jcr:content'
于 2014-07-23T07:41:59.253 回答
-3

您可以使用 crxde 中的“查询工具”轻松地将 xpath 转换为 sql2,反之亦然在此处输入图像描述

于 2014-07-23T14:57:06.363 回答