POM_XPATH_SET(7)
π POM_XPATH_SET(7) π
Java Packages Tools Β· the pom_xpath_set glow-up
okay bestie, pull up a chair because we're about to talk about the icon that is pom_xpath_set π
β¨ NAME β¨
pom_xpath_set β set contents of XML node from XML file π
β¨ SYNOPSIS β¨
%pom_xpath_set XPath new-contents [XML-file-location]
that's it. three little things. so simple. so powerful. periodt π«Ά
β¨ DESCRIPTION β¨
so what does this macro actually do, you ask? πΈ
It patches a specified POM file, replacing the contents of all XML nodes described by the XPath expression with the new text content you handed it. And the range?? literally immaculate β it works on both elements and attributes. no cap. π
XPath is an expression describing a set of XML nodes to be removed from the POM file. It has to be a properly formated XPath 1.0 expression, exactly as described over at http://www.w3.org/TR/xpath/ β so like, don't freestyle it, bestie, the spec is the spec π
now here's the part that gets people every single time, and I need you to hear me π
Maven POM files use a specific XML namespace, http://maven.apache.org/POM/4.0.0, as default. That namespace has to be explicitly specified in your XPath expressions by prefixing all node names with pom β so like, pom:modelVersion, not just modelVersion. the way that pom: prefix is non-negotiableβ¦ iconic of it honestly π
and it's not just Maven, bestie. Many other XML formats also use namespaces which you have to explicitly specify. This script will use the namespace prefix names from the xmlns declarations in the document's root element. So if the document begins with <root xmlns:my="myurl.com"> you would select the root node with the XPath expression /my:root. See how the prefix just β¨matchesβ¨? obsessed.
And if the document specifies a default namespace (eg xmlns="myurl.com") β listen β you use the prefix named default to acces elements in that namespace. yes, literally the word default. it's giving secret handshake π€
lastly, XML location can be either a full path to the XML, or a path to the directory containing pom.xml or ivy.xml. If XML location is not given, then pom.xml or ivy.xml from the current working directory is used. And when both pom.xml and ivy.xml are present?? pom.xml is processed β it wins, sorry ivy π
oh and you can specify more file locations. go off, specify as many as your heart desires π
β οΈ real talk: that XPath expression has to be valid XPath 1.0. if it's not, that's not a vibe, that's a bug report.
β¨ AUTHOR β¨
Written by Mikolaj Izdebski. king behavior, fr fr π
β¨ REPORTING BUGS β¨
Found a bug? π don't suffer in silence, bestie. Bugs should be reported through the Java Packages Tools issue tracker at Github:
https://github.com/fedora-java/javapackages/issues
β¨ SEE ALSO β¨
the whole friend group π«Ά go read these too:
pom_add_dep(7)pom_add_parent(7)pom_add_plugin(7)pom_disable_module(7)pom_remove_dep(7)pom_remove_parent(7)pom_remove_plugin(7)pom_set_parent(7)pom_xpath_inject(7)pom_xpath_remove(7)pom_xpath_replace(7)
and that's the whole page, bestie β¨ this one's from JAVAPACKAGES, dated 2025-09-19, and it's the POM_XPATH_SET(7) manual. go set some nodes. you got this ππ¦π
π¦ where this page comes from
- fedora 43: javapackages-common 6.4.1-4.fc43 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms