> If possible, can u share with us the XSLT u wrote to convert POMv3 to POMv4?

How did I _know_ that question was coming? :-)

Please find it attached.

  -- /v\atthew
<?xml version="1.0" encoding="UTF-8"?>
<!--
Version: 1.0

Copyright 2006 Matthew L Daniel [EMAIL PROTECTED]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at 

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
/-->
<!--
This xslt purposefully does not use xsl:copy-of for the same reason it injects
@xmlns into the project element: namespaces are not honored in either the v3
or v4 POM, and xsl:copy-of introduces more risk of NamespaceMania than it does
benefit.
/-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
        <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:template match='/'>
        <xsl:apply-templates select='project'/>
    </xsl:template>
    <xsl:template match='project'>
        <project>
            <xsl:attribute name='xmlns'
                >http://maven.apache.org/POM/4.0.0</xsl:attribute>
            <modelVersion>4.0.0</modelVersion>
            <xsl:choose>
                <xsl:when test='boolean(id) 
                    and not(boolean(groupId))
                    and contains(id, ":")'>
                    <groupId>
                        <xsl:value-of select='string-before(id,":")'/>
                    </groupId>
                    <artifactId>
                        <xsl:value-of select='string-after(id,":")'/>
                    </artifactId>
                </xsl:when>
                <xsl:when test='boolean(id) 
                    and not(boolean(groupId))
                    and not(contains(id, ":"))'>
                    <groupId><xsl:value-of select='id' /></groupId>
                    <artifactId><xsl:value-of select='id' /></artifactId>
                </xsl:when>
                <xsl:when test='boolean(id) 
                    and boolean(groupId)
                    and not(contains(id, ":"))'>
                    <groupId><xsl:value-of select='groupId' /></groupId>
                    <artifactId><xsl:value-of select='id' /></artifactId>
                </xsl:when>
                <xsl:otherwise>
                    <groupId>
                        <xsl:value-of select='groupId' />
                    </groupId>
                    <artifactId>
                        <xsl:value-of select='artifactId' />
                    </artifactId>
                </xsl:otherwise>
            </xsl:choose>
            <packaging>jar</packaging>
            <name><xsl:value-of select='name' /></name>
            <version>
                <xsl:value-of select='currentVersion' />
            </version>
            <description>
                <!-- use shortDescription since m2 puts this in the Jar
                Manifest, so it needs to be a one-liner -->
                <xsl:value-of select='shortDescription' />
            </description>
            <url><xsl:value-of select='url' /></url>
            <xsl:apply-templates select='dependencies' />
        </project>
    </xsl:template>
    <xsl:template match='dependencies'>
        <dependencies>
            <xsl:apply-templates select='dependency' />
        </dependencies>
    </xsl:template>
    <xsl:template match='dependency[id 
        and contains(id,":") 
        and not(groupId)]'>
        <dependency>
            <groupId>
                <xsl:value-of select='string-before(id,":")'/>
            </groupId>
            <artifactId>
                <xsl:value-of select='string-after(id,":")'/>
            </artifactId>
            <version><xsl:value-of select='version' /></version>
            <xsl:call-template name='typeOrDefault' />
        </dependency>
    </xsl:template>
    <xsl:template match='dependency[id 
        and not(contains(id,":")) 
        and not(groupId)]'>
        <dependency>
            <groupId><xsl:value-of select='id' /></groupId>
            <artifactId><xsl:value-of select='id' /></artifactId>
            <version><xsl:value-of select='version' /></version>
            <xsl:call-template name='typeOrDefault' />
        </dependency>
    </xsl:template>
    <xsl:template match='dependency[groupId]'>
        <dependency>
            <groupId><xsl:value-of select='groupId' /></groupId>
            <artifactId><xsl:value-of select='artifactId' /></artifactId>
            <version><xsl:value-of select='version' /></version>
            <xsl:call-template name='typeOrDefault' />
        </dependency>
    </xsl:template>
    <xsl:template name='typeOrDefault'>
        <xsl:choose>
            <xsl:when test='boolean(type)'>
                <type>
                    <xsl:value-of select='type' />
                </type>
            </xsl:when>
            <xsl:otherwise>
                <type>jar</type>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <!-- 
    there is a defect where 
    <version>${pom.currentVersion}</version>
    should be 
    <version>${pom.version}</version>
    if you have suggestions, more power to ya
    -->
</xsl:stylesheet>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to