Skip to content

Add support for "contains" in XML XPath matching #6053

@BrendanHart

Description

@BrendanHart

What version of OpenRewrite are you using?

I am using

  • OpenRewrite v8.62.2 (latest in main)

What is the smallest, simplest way to reproduce the problem?

    @Test
    void searchWithContains() {
        rewriteRun(
          spec -> spec.recipe(new FindTags("/dependencies/dependency[contains(artifactId, 'abc')]")),
          xml(
            """
            <dependencies>
                <dependency>
                    <artifactId>org.openrewrite</artifactId>
                </dependency>
            </dependencies>
            """,
            """
              <dependencies>
                  <!--~~>--><dependency>
                      <artifactId>org.openrewrite</artifactId>
                  </dependency>
              </dependencies>
              """
          )
        );
    }

What did you expect to see?

Test fails since artifactId does not contain abc.

What did you see instead?

Test passes.

Are you interested in contributing a fix to OpenRewrite?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions