Solved

replace version info in maven2 from pom.xml to another xml file

Posted on 2009-07-13
2
602 Views
Last Modified: 2013-11-18
I have several pom.xml files, contents of pom.xml is as follows:

pom.xml
--------
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.xkri.kill.tokens</groupId>
  <artifactId>tokens-active-dent</artifactId>
  <version>7.5.02.02</version>
  <!-- default packaging -->
  <packaging>jar</packaging>
  <name>Colt and ADAM</name>
  <description>This package provides the ${name}</description>
  :
  :
  :
 </project>

 I want to pick the version from node
 <version>7.5.02.02</version>
 and replace it to another config.xml:

 config.xml
 ----------
 <?xml version="1.0" encoding="UTF-8"?>
<installationTaskConfiguration xmlns="http://www.colt.com"
                               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                               xsi:schemaLocation="http://www.colt.com InstallationTaskConfiguration.xsd">
  <registryVersion product="" releaseVersion="7" majorVersion="5" minorVersion="02"/>
  <productFeature id="tokens-active-dent"
        parent="base-dent"
                    state="INSTALLING"
                    requiredDiskSpaceMode="default"
                    rebootRequiredOnInstall="false"
                    rebootRequiredOnUninstall="false"
                    rebootRequiredOnUpgrade="false"
                    backupOnUpgrade="false">
      <version product="" releaseVersion="7" majorVersion="5" minorVersion="02" subMinorVersion="SNAPSHOT"/>
      <requiredDiskSpaceMap>
        <requiredDiskSpace id="default" size="1MB"/>
        <requiredDiskSpace id="backup" size="0MB"/>
        <requiredDiskSpace id="temporary" size="0MB"/>
      </requiredDiskSpaceMap>
    </productFeature>
    :
    :
    :
 </installationTaskConfiguration>

 in config.xml file I want to reaplce in this format:
 <version product="" releaseVersion="7" majorVersion="5" minorVersion="02" subMinorVersion="02"/>
 can anyone give me an idea on how to copy and repace in above mentioend format?
0
Comment
Question by:saharey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 4

Accepted Solution

by:
phdesign earned 50 total points
ID: 24846854
This should work.
<?xml version="1.0" encoding="utf-8"?>
 
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:pom="http://maven.apache.org/POM/4.0.0">
 
<xsl:template match="/">
	<installationTaskConfiguration xmlns="http://www.colt.com"
								   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
								   xsi:schemaLocation="http://www.colt.com InstallationTaskConfiguration.xsd">
		<registryVersion product="">
			<xsl:attribute name="releaseVersion">
				<xsl:value-of select="substring-before(/pom:project/pom:version,'.')"/>
			</xsl:attribute>
			<xsl:attribute name="majorVersion">
				<xsl:value-of select="substring-before(substring-after(/pom:project/pom:version,'.'),'.')"/>
			</xsl:attribute>
			<xsl:attribute name="minorVersion">
				<xsl:value-of select="substring-before(substring-after(substring-after(/pom:project/pom:version,'.'),'.'),'.')"/>
			</xsl:attribute>
			<xsl:attribute name="subMinorVersion">
				<xsl:value-of select="substring-after(substring-after(substring-after(/pom:project/pom:version,'.'),'.'),'.')"/>
			</xsl:attribute>
		</registryVersion>
	</installationTaskConfiguration>
</xsl:template>
 
</xsl:stylesheet> 

Open in new window

0
 
LVL 4

Expert Comment

by:phdesign
ID: 24874696
Did it?
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SAMI File <SYNC Start = (number of millisecond)> Question 3 96
CSS HELP 6 103
Getting attribute Values using xslt 4 67
Randomize in Owl Carousel v1.3.2 6 133
It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question