Update groove script with XPath query using "contains"


We are interested in implementing an update groovy script that updates all nodes, at any level, that contains a given word in a given attribute value

XPath documentation offers the contains method to select all nodes that contain a given string.

However, trying to use the contains function in /cms/repository like this

//*[contains(@hst:parametervalues, 'mytext')]

returns the next error

and also testing it in the Updated editor we get a similar error:

Is there any way to achieve something like this?

The idea is to use the script to update the hst:parametervalues attribute value for all the nodes that have a given string inside that attribute, anywhere in the repository

Thanks in advance

Please try this:

//*[jcr:contains(@hst:parametervalues, 'mytext')]
1 Like

that worked like a charm… any chance that could land on the official documentation? Other functions as well perhaps?

That would surely save someone else’s time in the future.

Thanks a ton @woonsanko!

this was already correct in our examples:

1 Like