I am trying to create an xpath query to select JCR nodes of multiple primary types.
For example, I could write a query like this:
/jcr:root/content//element(*, nt:unstructured)
to select all the nodes of type nt:unstructured, or this:
/jcr:root/content//element(*, nt:file)
to get all the nodes of type nt:file
Is it possible to write one query to select all the nodes of type nt:unstructured and of type nt:file?
You can use a where clause in which you filter on jcr:primaryType
/jcr:root/content//*[@jcr:primaryType='nt:file' or @jcr:primaryType='nt:unstructured']
Keep in mind that the queries you provided as an example also select on multiple types (namely super and child types.
Let's say you have a node of type project:article and a project:newsarticle in which newsarticle is extending the article node type.
When querying with
/jcr:root/content//element(*, project:article)
You will also find the nodes of both types.