Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for XML Namespaces #3919

Closed
ammachado opened this issue Jan 16, 2024 · 7 comments
Closed

Support for XML Namespaces #3919

ammachado opened this issue Jan 16, 2024 · 7 comments
Labels
enhancement New feature or request

Comments

@ammachado
Copy link
Contributor

ammachado commented Jan 16, 2024

What problem are you trying to solve?

Change namespaced tags without being required to know the namespace prefix. For example, on the following XML, I want to replace the schemaLocation attribute on the beans tag.

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
</bean>

There are situations where the namespace URI remains the same, but the prefix changes. I can try change the attribute xsi:schemaLocation, but for that the prefix should match.

Describe the solution you'd like

Have you considered any alternatives or workarounds?

No.

Additional context

Are you interested in contributing this feature to OpenRewrite?

@ammachado ammachado added the enhancement New feature or request label Jan 16, 2024
@timtebeek
Copy link
Contributor

Seems reasonable, thanks! Might tie into some of the schemaLocation changes we do in rewrite-migrate-java.

@ammachado
Copy link
Contributor Author

Probably a few of the existing Java EE9/10 recipes could be improved with this, also create new ones, specially new recipes to refactor schemaLocation for Spring XML files.

ammachado added a commit to ammachado/rewrite that referenced this issue Jan 18, 2024
timtebeek pushed a commit that referenced this issue Jan 18, 2024
@knutwannheden
Copy link
Contributor

With that PR merged, I think this ticket can now be closed. What fo you guys think, @ammachado and @timtebeek ?

@timtebeek
Copy link
Contributor

We had added a disabled tests previously; think we can reevaluate the @Disabled on that tests before we close

@Test
@Disabled
@Issue("https://github.com/openrewrite/rewrite/issues/3919")
void matchFunctions() {

@ammachado
Copy link
Contributor Author

#3925 does not consider namespaces on org.openrewrite.xml.SemanticallyEqual.

@evie-lau
Copy link
Contributor

Also need to finish support for name and namespace-uri functions in XPathMatcher. The latter function may potentially require a refactor or rewrite.

@timtebeek
Copy link
Contributor

I feel this has been handled and then last refined in

Let's pick up any remaining work separately as the context has shifted quite a bit since this was opened. Thanks all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

No branches or pull requests

4 participants