How to write a xpath query to check all the title properties in metadata node of an asset | Community
Skip to main content
Level 3
May 21, 2024

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

  • May 21, 2024
  • 2 replies
  • 1450 views

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.

 


Any suggestion on this.
Thanks and Regards

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

HrishikeshKagne
Community Advisor
Community Advisor
May 21, 2024

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.

Hrishikesh Kagane
VedhaSriAuthor
Level 3
May 21, 2024

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

 

TarunKumar
Community Advisor
Community Advisor
May 21, 2024

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

VedhaSriAuthor
Level 3
May 21, 2024

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.