How to do a Query in JCR XPATH

I have a simple data structure : Person (name,age,gender)

name, age , gender

  1. sola, 48 male
  2. carol 40 female
  3. ishani 12 female

I need a simple to find where names = “sola” with a published status.

i did a simple xpath query and it was successful

//element(*,xxxxxxxx:Person)/@jcr:path[@hippostd:state = ‘published’]

BUT when I try this

//element(*,xxxxxxxx:Person)/@jcr:path[@hippostd:state = ‘published’ and @name=‘sola’]

I get blank because the actual value of name=sola is found inside that jcr:path.

How do I create a query or maybe a sub-query to search the value inside thet jcr:path

wouldn’t the following suffice?

//element(*,xxxxxxxx:Person)[@hippostd:state = ‘published’ and @name=‘sola’]

1 Like

Thanks Jasper.floor

I tried that too, it did not work.

Maybe I need to clarify, sorry for my weak explanation yesterday.


In the http://localhost:8080/cms/respository, if I choose XPath and paste the following query

//element(*,xxxxxxxx:Person)/@jcr:path[@hippostd:state = ‘published’]

I will get the following links:

/content/documents/xxxxxxxx/Person/person1/person1[3]
/content/documents/xxxxxxxx/Person/person2/person2[3]
/content/documents/xxxxxxxx/Person/person3/person3[3]

And the table with columns(#,jcr:path,jcr:score)

1 /content/documents/xxxxxxxx/Person/person1/person1[3] 12947
2 /content/documents/xxxxxxxx/Person/person2/person2[3] 12947
3 /content/documents/xxxxxxxx/Person/person3/person3[3] 12947

Only if I click on the links (I assume to be the subquery) for example

/content/documents/xxxxxxxx/Person/person1/person1[3]

Then I will be able to see the list of values

Access node : /[root/content/document/xxxxxxxx/person/person1

  • [name=“xxxxxxxx:name”] = Sola
  • [name=“xxxxxxxx:age”] = 48
  • [name=“xxxxxxxx:gender”] = male

Is there a query I can call like you example:

//element(*,xxxxxxxx:Person)[@hippostd:state = ‘published’ and @name=‘sola’]

Yes jasper you are right with a small tweak, the answer is

//element(*,xxxxxxxx:Person)[@hippostd:state = ‘published’ and @xxxxxxxx:name=‘sola’]

Thank you

1 Like

Great, thanks for letting us know you reached a solution!