Open ammachado opened 5 months ago
Seems reasonable, thanks! Might tie into some of the schemaLocation
changes we do in rewrite-migrate-java.
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.
With that PR merged, I think this ticket can now be closed. What fo you guys think, @ammachado and @timtebeek ?
We had added a disabled tests previously; think we can reevaluate the @Disabled
on that tests before we close
https://github.com/openrewrite/rewrite/blob/22ac272d0a37fe1023af153ec68aef3ab7926849/rewrite-xml/src/test/java/org/openrewrite/xml/XPathMatcherTest.java#L223-L226
org.openrewrite.xml.SemanticallyEqual
.Also need to finish support for name
and namespace-uri
functions in XPathMatcher. The latter function may potentially require a refactor or rewrite.
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 thebeans
tag.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
ChangeTagAttribute
(I already have this working, I will contribute a PR#3920);name
,onnamespace-uri
andlocal-name
XPathMatcher
; #3925 and #4287Add a#3925 andnamespaces
field onXml.Document
andXml.Tag
, mapping the declared prefixes and namespaces;Add a#3925namespace
or anamespacePrefix
field onXml.Tag
andXml.Attribute
, identifying the namespace of that particular tag/attribute.Have you considered any alternatives or workarounds?
No.
Additional context
Are you interested in contributing this feature to OpenRewrite?