Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The part that does all the actual work is the following XSLT definition (ivy-report-appxml14.xsl in the above example):

Code Block
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:output indent="yes"/>

    <xsl:variable name="modules" select="/ivy-report/dependencies/module"/>
    <xsl:variable name="revisions" select="$modules/revision"/>
    <xsl:variable name="artifacts" select="$revisions/artifacts/artifact"/>
    
    <xsl:template name="calling">
        <xsl:param name="org"/>
        <xsl:param name="mod"/>
        <xsl:param name="rev"/>
        <xsl:if test="count($modules/revision/caller[(@organisation=$org and @name=$mod) and @callerrev=$rev]) > 0">
            <module>
               <xsl:for-each select="$modules/revision/caller[(@organisation=$org and @name=$mod) and @callerrev=$rev]">
                 <xsl:call-template name="called">
                   <xsl:with-param name="revision" select=".."/>
                 </xsl:call-template>
               </xsl:for-each>   
            </module>
        </xsl:if>
    </xsl:template>
    
    <xsl:template name="called">
        <xsl:param name="revision"/>
    
        <xsl:param name="module" select="$revision/../@name"/>
        <xsl:param name="rev" select="$revision/@name"/>
        <xsl:param name="type" select="$revision/artifacts/artifact/@type"/>
        <xsl:param name="ext" select="$revision/artifacts/artifact/@ext"/>
        <xsl:param name="artifact" select="concat($module, '-', $rev, '.', $ext)"/>
        
        <xsl:if test="$type='ejb'">
            <ejb>
                <xsl:value-of select="$artifact"/>
            </ejb>
        </xsl:if>
        
        <xsl:if test="$type='war'">
            <web>
                <web-uri>
                    <xsl:value-of select="$artifact"/>
                </web-uri>
            </web>
        </xsl:if>

        <xsl:if test="$type='jar'">
            <web>
                <module>
                    <java><xsl:value-of select="$artifact"/></java>
                </module>
            </web>
        </xsl:if>
    </xsl:template>
    
    <xsl:template match="/ivy-report">
        <application version="1.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
            <display-name><xsl:value-of select="info/@module"/></display-name>
            <xsl:call-template name="calling">
                <xsl:with-param name="org" select="info/@organisation"/>
                <xsl:with-param name="mod" select="info/@module"/>
                <xsl:with-param name="rev" select="info/@revision"/>
            </xsl:call-template>
        </application>
    </xsl:template>

</xsl:stylesheet>

...