Solved

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

Posted on 2009-07-13
2
578 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
  • 2
2 Comments
 
LVL 4

Accepted Solution

by:
phdesign earned 50 total points
Comment Utility
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
Comment Utility
Did it?
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

744 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now