I am working on pom file modifications to change the version node value. I can get xpath to modify all version nodes, but I only want it to change the version node when both the artifactId and classifier match certain values. Here is my xml:
<artifactItem>
<groupId>com.xyz</groupId>
<artifactId>foobar</artifactId>
<version>${project.version}</version>
<classifier>config</classifier>
<type>zip</type>
<overWrite>true</overWrite>
</artifactItem>
<artifactItem>
<groupId>com.xyz</groupId>
<artifactId>foobar</artifactId>
<version>${project.version}</version>
<type>jar</type>
</artifactItem>
If artifactId is foobar, and classifier is config, I want version returned so I can modify it.
Using other examples I found, I tried this, but it didn’t work:
/artifactItem/artifactId[.='foobar']
/following-sibling::*
[count(.|/artifactItem/classifier[. ='config']/preceding-sibling::*)
=
count(/artifactItem/classifier[. ='config']/preceding-sibling::*)
]
Any suggestions would be greatly appreciated!
thanks
To explain:
We are selecting the version node, from the artifactItem node that has an artifactId of ‘foobar’ AND a classifier of ‘config’.
You use the brackets to qualify a particular node using sub-XPATH statements where the context is the node before the brackets.
Is this what you are looking for?