XPath issue in Maven replacer plugin -
i following error when trying use xpath replace in web.xml maven replacer plugin
[error] failed execute goal com.google.code.maven-replacer-plugin:replacer:1.5.2:replace (default) on project my-project: error during xml replacement: content not allowed in prolog. -> [help 1]
and here's maven code
<plugin> <groupid>com.google.code.maven-replacer-plugin</groupid> <artifactid>replacer</artifactid> <version>1.5.2</version> <executions> <execution> <phase>prepare-package</phase> <goals> <goal>replace</goal> </goals> </execution> </executions> <configuration> <file>src/main/webapp/web-inf/web.xml</file> <outputfile>target/web.xml</outputfile> <regexflags> <regexflag>case_insensitive</regexflag> </regexflags> <replacements> <replacement> <xpath>/web-app/display-name</xpath> <token>.*</token> <value>${project.name}</value> </replacement> </replacements> </plugin>
web.xml
<?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="my-project" version="2.5"> <display-name>my project</display-name> ... </web-app>
any idea why?
you need register "http://java.sun.com/xml/ns/javaee" namespace, , choose prefix, let's "javaee", , use /javaee:web-app/javaee:display-name
xpath expression.
according link, can in plugin's <configuration>
section:
<plugin> ... <configuration> <namespacecontexts> <javaee>http://java.sun.com/xml/ns/javaee</javaee> </namespacecontexts> ...
Comments
Post a Comment