Skip to content

Commit 98c728b

Browse files
committed
Rename ChangeTagAttributeKey.xPath option for consistency
1 parent 3a056f6 commit 98c728b

3 files changed

Lines changed: 4 additions & 6 deletions

File tree

rewrite-xml/src/main/java/org/openrewrite/xml/ChangeTagAttributeKey.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class ChangeTagAttributeKey extends Recipe {
3030
@Option(displayName = "Attribute XPath",
3131
description = "XPath expression to match the attribute.",
3232
example = "//a4j:ajax/@reRender")
33-
String elementXPath;
33+
String xPath;
3434

3535
@Option(displayName = "New attribute name",
3636
description = "The new name for the attribute.",
@@ -39,7 +39,7 @@ public class ChangeTagAttributeKey extends Recipe {
3939

4040
@Override
4141
public TreeVisitor<?, ExecutionContext> getVisitor() {
42-
XPathMatcher xPathMatcher = new XPathMatcher(elementXPath);
42+
XPathMatcher xPathMatcher = new XPathMatcher(xPath);
4343
return new XmlIsoVisitor<ExecutionContext>() {
4444
@Override
4545
public Xml.Attribute visitAttribute(Xml.Attribute attribute, ExecutionContext ctx) {

rewrite-xml/src/main/resources/META-INF/rewrite/examples.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,8 @@ recipeName: org.openrewrite.xmlChangeTagAttributeKey
141141
examples:
142142
- description: '`ChangeXmlAttributeTest#renameReRenderToRender`'
143143
parameters:
144-
- //a4j:ajax
145-
- reRender
144+
- //a4j:ajax/@reRender
146145
- render
147-
- '**/*.xhtml'
148146
sources:
149147
- before: |
150148
<?xml version="1.0" encoding="UTF-8"?>

rewrite-xml/src/main/resources/META-INF/rewrite/recipes.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ maven,org.openrewrite:rewrite-xml,org.openrewrite.xml.AddOrUpdateChildTag,Add or
44
maven,org.openrewrite:rewrite-xml,org.openrewrite.xml.AddTagAttribute,Add new XML attribute for an Element,Add new XML attribute with value on a specified element.,1,,XML,,Basic building blocks for transforming XML.,"[{""name"":""elementName"",""type"":""String"",""displayName"":""Element name"",""description"":""The name of the element whose attribute's value is to be added. Interpreted as an XPath expression."",""example"":""//beans/bean"",""required"":true},{""name"":""attributeName"",""type"":""String"",""displayName"":""Attribute name"",""description"":""The name of the new attribute."",""example"":""attribute-name"",""required"":true},{""name"":""newValue"",""type"":""String"",""displayName"":""New value"",""description"":""The new value to be used for key specified by `attributeName`."",""example"":""value-to-add"",""required"":true}]",
55
maven,org.openrewrite:rewrite-xml,org.openrewrite.xml.ChangeNamespaceValue,Change XML attribute of a specific resource version,Alters XML Attribute value within specified element of a specific resource versions.,1,,XML,,Basic building blocks for transforming XML.,"[{""name"":""elementName"",""type"":""String"",""displayName"":""Element name"",""description"":""The name of the element whose attribute's value is to be changed. Interpreted as an XPath Expression."",""example"":""property""},{""name"":""oldValue"",""type"":""String"",""displayName"":""Old value"",""description"":""Only change the property value if it matches the configured `oldValue`."",""example"":""newfoo.bar.attribute.value.string""},{""name"":""newValue"",""type"":""String"",""displayName"":""New value"",""description"":""The new value to be used for the namespace."",""example"":""newfoo.bar.attribute.value.string"",""required"":true},{""name"":""versionMatcher"",""type"":""String"",""displayName"":""Resource version"",""description"":""The version of resource to change"",""example"":""1.1""},{""name"":""searchAllNamespaces"",""type"":""Boolean"",""displayName"":""Search all namespaces"",""description"":""Specify whether evaluate all namespaces. Defaults to true"",""example"":""true""},{""name"":""newVersion"",""type"":""String"",""displayName"":""New Resource version"",""description"":""The new version of the resource"",""example"":""2.0"",""required"":true},{""name"":""newSchemaLocation"",""type"":""String"",""displayName"":""Schema location"",""description"":""The new value to be used for the namespace schema location."",""example"":""newfoo.bar.attribute.value.string""}]",
66
maven,org.openrewrite:rewrite-xml,org.openrewrite.xml.ChangeTagAttribute,Change XML attribute,Alters XML attribute value on a specified element.,1,,XML,,Basic building blocks for transforming XML.,"[{""name"":""elementName"",""type"":""String"",""displayName"":""Element name"",""description"":""The name of the element whose attribute's value is to be changed. Interpreted as an XPath expression."",""example"":""property"",""required"":true},{""name"":""attributeName"",""type"":""String"",""displayName"":""Attribute name"",""description"":""The name of the attribute whose value is to be changed."",""example"":""name"",""required"":true},{""name"":""newValue"",""type"":""String"",""displayName"":""New value"",""description"":""The new value to be used for key specified by `attributeName`, Set to null if you want to remove the attribute."",""example"":""newfoo.bar.attribute.value.string"",""required"":true},{""name"":""oldValue"",""type"":""String"",""displayName"":""Old value"",""description"":""Only change the property value if it matches the configured `oldValue`."",""example"":""foo.bar.attribute.value.string""},{""name"":""regex"",""type"":""Boolean"",""displayName"":""Regex"",""description"":""Default false. If true, `oldValue` will be interpreted as a Regular Expression, and capture group contents will be available in `newValue`.""}]",
7-
maven,org.openrewrite:rewrite-xml,org.openrewrite.xml.ChangeTagAttributeKey,Change XML attribute key,Change an attributes key on XML elements using an XPath expression.,1,,XML,,Basic building blocks for transforming XML.,"[{""name"":""elementXPath"",""type"":""String"",""displayName"":""Attribute XPath"",""description"":""XPath expression to match the attribute."",""example"":""//a4j:ajax/@reRender"",""required"":true},{""name"":""newAttributeName"",""type"":""String"",""displayName"":""New attribute name"",""description"":""The new name for the attribute."",""example"":""render"",""required"":true}]",
7+
maven,org.openrewrite:rewrite-xml,org.openrewrite.xml.ChangeTagAttributeKey,Change XML attribute key,Change an attributes key on XML elements using an XPath expression.,1,,XML,,Basic building blocks for transforming XML.,"[{""name"":""xPath"",""type"":""String"",""displayName"":""Attribute XPath"",""description"":""XPath expression to match the attribute."",""example"":""//a4j:ajax/@reRender"",""required"":true},{""name"":""newAttributeName"",""type"":""String"",""displayName"":""New attribute name"",""description"":""The new name for the attribute."",""example"":""render"",""required"":true}]",
88
maven,org.openrewrite:rewrite-xml,org.openrewrite.xml.ChangeTagName,Change XML tag name,Alters the name of XML tags matching the provided expression.,1,,XML,,Basic building blocks for transforming XML.,"[{""name"":""elementName"",""type"":""String"",""displayName"":""Element name"",""description"":""The name of the element whose attribute's value is to be changed. Interpreted as an XPath expression."",""example"":""/settings/servers/server/username"",""required"":true},{""name"":""newName"",""type"":""String"",""displayName"":""New name"",""description"":""The new name for the tag."",""example"":""user"",""required"":true}]",
99
maven,org.openrewrite:rewrite-xml,org.openrewrite.xml.ChangeTagValue,Change XML tag value,Alters the value of XML tags matching the provided expression. When regex is enabled the replacement happens only for text nodes provided the pattern matches.,1,,XML,,Basic building blocks for transforming XML.,"[{""name"":""elementName"",""type"":""String"",""displayName"":""Element name"",""description"":""The name of the element whose value is to be changed. Interpreted as an XPath Expression."",""example"":""/settings/servers/server/username"",""required"":true},{""name"":""oldValue"",""type"":""String"",""displayName"":""Old value"",""description"":""The old value of the tag. Interpreted as pattern if regex is enabled."",""example"":""user""},{""name"":""newValue"",""type"":""String"",""displayName"":""New value"",""description"":""The new value for the tag. Supports capture groups when regex is enabled. If literal $,\\ characters are needed in newValue, with regex true, then it should be escaped."",""example"":""user"",""required"":true},{""name"":""regex"",""type"":""Boolean"",""displayName"":""Regex"",""description"":""Default false. If true, `oldValue` will be interpreted as a [Regular Expression](https://en.wikipedia.org/wiki/Regular_expression), and capture group contents will be available in `newValue`.""}]",
1010
maven,org.openrewrite:rewrite-xml,org.openrewrite.xml.RemoveEmptyXmlTags,Remove empty XML Tag,"Removes XML tags that do not have attributes or children, including self closing tags.",1,,XML,,Basic building blocks for transforming XML.,,

0 commit comments

Comments
 (0)