Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

How to write a xpath query to check all the title properties in metadata node of an asset

Avatar

Level 3

I would like to compare the search query to all the language titles of an asset which is stored on metadata node of the asset. So I tried to write an Xpath query like this but its not working.

VedhaSri_0-1716274605366.png

 


Any suggestion on this.
Thanks and Regards

4 Replies

Avatar

Community Advisor

Hi @VedhaSri ,

To check all the `title` properties in the metadata node of an asset using XPath, you can use the following query:

```
/jcr:content/metadata//*[local-name()='title']
```

This query selects all elements with a local name of `title` that are descendants of the `metadata` node under the `jcr:content` node of the asset.

To compare the search query to all the language titles of an asset, you can modify the query to include a predicate that filters the `title` elements based on their language attribute. For example, to select all `title` elements with a `language` attribute of `en`, you can use the following query:

```
/jcr:content/metadata//*[local-name()='title' and @language='en']
```

This query selects all `title` elements with a `language` attribute of `en` that are descendants of the `metadata` node under the `jcr:content` node of the asset.

You can replace `en` with the desired language code to select the `title` elements for that language. If you want to select all `title` elements regardless of their language, you can remove the `and @language='en'` predicate from the query.

Avatar

Level 3

Hi @HrishikeshKa, I tried the query but it is not working. could you please have look and I need to query all the titles at once.

VedhaSri_0-1716286385670.png

 

Avatar

Community Advisor

HI @VedhaSri ,

You can write an Xpath query something like below. Here I've only mentioned for "es" but you can write as many as per your need.

/jcr:root/content/dam//element(*, dam:Asset)
[
(jcr:content/metadata/@dc:title_es = 'es-test' or jcr:content/metadata/@dc:title_en = 'en-test')
]

 

 

Thanks
tarun

Avatar

Level 3

Hi @TarunKumar , I wanted to query all the titles at once instead of adding all the titles individually as there are more than 30 language titles are there. Is that possible to query like that.