3

Looking to use a wildcard in an xpath where the attribute is a path and I want all paths that end with "text".

Example: <Property name="jcr:content/MainParsys/*/text"/>

  • jcr:content/MainParsys is constant.
  • * is where I want the wildcard (all paths in-between).
  • text is the last part of the path I am looking for.

In addition, there are paths that end in /textIsRich that I want to avoid.

Look for: <Property name="jcr:content/MainParsys/*/text"/>

Avoid: <Property name="jcr:content/MainParsys/*/text *"/>

kjhughes
  • 106,133
  • 27
  • 181
  • 240
Max
  • 43
  • 2

1 Answers1

3

XPath 1.0

This XPath,

//Property[@name[  starts-with(.,'jcr:content/MainParsys/')
         and substring(., string-length(.) - string-length('/text') +1) = '/text']]

will select all Property elements with an name attribute whose value starts with 'jcr:content/MainParsys/' and ends with '/text' (using the standard XPath 1.0 work-around for no ends-with() function).

XPath 2.0

XPath 2.0 has ends-with() and also regex functions such as matches() that can match effective wildcards (.*), for example.

kjhughes
  • 106,133
  • 27
  • 181
  • 240