Index: ./proposal/antgump/xsl/antgump-each.xsl
===================================================================
RCS file: /home/cvspublic/jakarta-alexandria/proposal/antgump/xsl/antgump-each.xsl,v
retrieving revision 1.1
diff -u -r1.1 antgump-each.xsl
--- ./proposal/antgump/xsl/antgump-each.xsl	2001/04/01 05:24:21	1.1
+++ ./proposal/antgump/xsl/antgump-each.xsl	2001/04/18 17:04:13
@@ -1,7 +1,7 @@
 <xsl:stylesheet version="1.0"
-                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                xmlns:saxon="http://icl.com/saxon"
-                extension-element-prefixes="saxon">
+		xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+		xmlns:saxon="http://icl.com/saxon"
+		extension-element-prefixes="saxon">
 	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>
 	<xsl:strip-space elements="*"/>
 	<xsl:param name="output-dir"/>
@@ -9,236 +9,168 @@
 	<xsl:template match="/workspace">
 		<xsl:apply-templates/>
 	</xsl:template>
+	
+	
 	<xsl:template match="/workspace/project">
 		<xsl:variable name="basedir" select="/workspace/@basedir"/>
 		<xsl:variable name="cvsdir">
-                  <xsl:value-of select="/workspace/@cvsdir"/>
-                  <xsl:text>/</xsl:text>
-                  <xsl:choose>
-                    <xsl:when test="cvs/@module">
-                      <xsl:value-of select="cvs/@module"/>
-                    </xsl:when>
-                    <xsl:otherwise>
-                      <xsl:value-of select="@srcdir"/>
-                    </xsl:otherwise>
-                  </xsl:choose>
-                </xsl:variable>
-                <xsl:message terminate="no">
-                  <xsl:text>Creating Gump buildfile for </xsl:text>
-                  <xsl:value-of select="@name"/>
-                </xsl:message>
+		  <xsl:value-of select="concat(/workspace/@cvsdir, '/')"/>
+		  <xsl:choose>
+		    <xsl:when test="cvs/@module">
+		      <xsl:value-of select="cvs/@module"/>
+		    </xsl:when>
+		    <xsl:otherwise>
+		      <xsl:value-of select="@srcdir"/>
+		    </xsl:otherwise>
+		  </xsl:choose>
+		</xsl:variable>
+		<xsl:message terminate="no">
+		  <xsl:value-of select="concat('Creating Gump buildfile for ', @name)"/>
+		</xsl:message>
+		
 		<saxon:output file="{$basedir}/{@name}-gumpbuild.xml">
 			<project name="{@name} Gump build file" default="gumpify" basedir="{$basedir}/{@srcdir}">
+				
+				<!-- initialize time stamp and replace it in the html page -->
 				<target name="init">
-					<tstamp/>
+					<tstamp>
+						<format property="TIMESTAMP" pattern="HH:mm:ss"/>
+					</tstamp>
+					<replace file="{$basedir}/index.html" token="TAG-{@name}-TIME" value="${{TIMESTAMP}}"/>
 					<touch file="{$basedir}/{@name}.FAILED"/>
 				</target>
+				
+				<!-- check for all dependencies -->
 				<target name="dependency-check">
 					<xsl:apply-templates select="depend" mode="dependency-check"/>
 				</target>
+				
+				<!-- generate the dependency failure targets -->
 				<xsl:apply-templates select="depend" mode="failed-dependency"/>
+				
+				<!-- generate the main target that does everything -->
 				<target name="gumpify" depends="init,dependency-check" unless="dependency-failure">
 					<available file="{$cvsdir}" property="cvsmodule.{@name}.present"/>
-					<replace file="{$basedir}/index.html">
-                                          <xsl:attribute name="token">
-                                            <xsl:text>TAG-</xsl:text>
-                                            <xsl:value-of select="@name"/>
-                                            <xsl:text>-TIME</xsl:text>
-                                          </xsl:attribute>
-						<xsl:attribute name="value">
-							<xsl:text>${TSTAMP}</xsl:text>
-						</xsl:attribute>
-					</replace>
 					<echo message="In GUMP project: {@name}"/>
 					<xsl:if test="cvs">
 						<antcall target="cvscheckout"/>
-                                                <!--<antcall target="cvsupdate"/>-->
+						<!--<antcall target="cvsupdate"/>-->
 						<copy todir="{$basedir}/{@srcdir}">
-						        <fileset dir="{$cvsdir}"/>
+							<fileset dir="{$cvsdir}"/>
 						</copy>
 					</xsl:if>
-					<replace file="{$basedir}/cvs_index.html">
-                                          <xsl:attribute name="token">
-                                            <xsl:text>TAG-</xsl:text>
-                                            <xsl:value-of select="@name"/>
-                                            <xsl:text>-CVS-TIME</xsl:text>
-                                          </xsl:attribute>
-						<xsl:attribute name="value">
-							<xsl:text>${TSTAMP}</xsl:text>
-						</xsl:attribute>
-					</replace>
+					<replace file="{$basedir}/cvs_index.html" token="TAG-{@name}-CVS-TIME" value="${{TIMESTAMP}}"/>
 					<antcall target="build"/>
 					<antcall target="status-pages"/>
 					<move file="{$basedir}/{@name}.FAILED" tofile="{$basedir}/{@name}.SUCCESS"/>
 				</target>
+				
 				<xsl:apply-templates select="cvs">
 					<xsl:with-param name="target" select="'cvscheckout'"/>
 					<xsl:with-param name="command" select="'-z3 checkout -P'"/>
 				</xsl:apply-templates>
+				
 				<xsl:apply-templates select="cvs">
 					<xsl:with-param name="target" select="'cvsupdate'"/>
 					<xsl:with-param name="command" select="'-z3 update -P -d -A'"/>
 				</xsl:apply-templates>
+				
+				<!-- build targets -->
 				<target name="build" depends="init">
 					<xsl:apply-templates select="ant | script"/>
 				</target>
+				
+				<!-- called if the build went fine it sets the status to SUCCESS in the html file -->
 				<target name="status-pages">
-                                  <replace file="{$basedir}/index.html" value="SUCCESS">
-                                          <xsl:attribute name="token">
-                                            <xsl:text>TAG-</xsl:text>
-                                            <xsl:value-of select="@name"/>
-                                            <xsl:text>-STATUS</xsl:text>
-                                          </xsl:attribute>
-                                  </replace>
-                                  <!--
-                                  <style in="" out="{/workspace/@basedir}/{@name}.html" style="" destdir="{/workspace/@basedir}"/>
--->
+				<replace file="{$basedir}/index.html" token="TAG-{@name}-STATUS" value="SUCCESS"/>				
+				  <!-- <style in="" out="{/workspace/@basedir}/{@name}.html" style="" destdir="{/workspace/@basedir}"/> -->
 				</target>
 			</project>
 		</saxon:output>
 	</xsl:template>
+	
+	
+	<!-- ===========================================================================================
+		Execute a Ant build file/target as specified by the project
+		 =========================================================================================== -->
 	<xsl:template match="/workspace/project/ant">
-		<java classname="org.apache.tools.ant.Main" fork="yes" failonerror="no">
-			<xsl:attribute name="output">
-				<xsl:value-of select="/workspace/@basedir"/>
-				<xsl:text>/</xsl:text>
-				<xsl:value-of select="../@name"/>
-				<xsl:text>-buildresult.txt</xsl:text>
-			</xsl:attribute>
-			<xsl:attribute name="dir">
-				<xsl:value-of select="/workspace/@basedir"/>
-				<xsl:text>/</xsl:text>
-				<xsl:value-of select="../@srcdir"/>
-				<xsl:if test="@basedir">
-					<xsl:text>/</xsl:text>
-					<xsl:value-of select="@basedir"/>
-				</xsl:if>
-			</xsl:attribute>
+		<!-- Ant build file directory -->
+		<xsl:variable name="build.dir">
+			<xsl:value-of select="concat(/workspace/@basedir, '/', ../@srcdir)"/>
+			<xsl:if test="@basedir">
+				<xsl:value-of select="concat('/', @basedir)"/>
+			</xsl:if>
+		</xsl:variable>				
+		
+		<!-- execute the target needed to build the project -->
+		<java classname="org.apache.tools.ant.Main" fork="yes" failonerror="yes"
+			output="{/workspace/@basedir}/{../@name}-buildresult.txt"
+			dir="{$build.dir}">
+			
+			<!-- a buildfile might be specified otherwise Ant will use its default -->
 			<xsl:if test="@buildfile">
-				<arg>
-					<xsl:attribute name="value">
-						<xsl:text>-buildfile </xsl:text>
-						<xsl:value-of select="/workspace/@basedir"/>
-						<xsl:text>/</xsl:text>
-						<xsl:value-of select="../@srcdir"/>
-						<xsl:text>/</xsl:text>
-						<xsl:if test="@basedir">
-							<xsl:value-of select="@basedir"/>
-							<xsl:text>/</xsl:text>
-						</xsl:if>
-						<xsl:value-of select="@buildfile"/>
-					</xsl:attribute>
-				</arg>
+				<arg line="-buildfile {$build.dir}/{@buildfile}"/>
+			</xsl:if>
+			<arg line="-listener org.apache.tools.ant.XmlLogger -DXmlLogger.file={/workspace/@basedir}/{../@name}-buildresult.xml"/>
+
+			<!-- specific target name to perform the build -->
+			<xsl:if test="@target">
+				<arg value="{@target}"/>
 			</xsl:if>
-			<xsl:choose>
-				<xsl:when test="@target">
-					<arg value="{@target}"/>
-				</xsl:when>
-				<xsl:otherwise/>
-			</xsl:choose>
 			<xsl:apply-templates select="property"/>
+			
 			<!-- Do the classpath thing here -->
 			<classpath>
-				<xsl:for-each select="../depend">
-					<xsl:variable name="name" select="@project"/>
-					<xsl:for-each select="/workspace/project[@name=$name]/jar">
-						<pathelement>
-							<xsl:attribute name="location">
-								<xsl:value-of select="../home"/>
-								<xsl:text>/</xsl:text>
-								<xsl:value-of select="@name"/>
-							</xsl:attribute>
-						</pathelement>	
-					</xsl:for-each>
-				</xsl:for-each>
-				<xsl:for-each select="../option">
+				<xsl:for-each select="../depend | ../option">
 					<xsl:variable name="name" select="@project"/>
 					<xsl:for-each select="/workspace/project[@name=$name]/jar">
-						<pathelement>
-							<xsl:attribute name="location">
-								<xsl:value-of select="../home"/>
-								<xsl:text>/</xsl:text>
-								<xsl:value-of select="@name"/>
-							</xsl:attribute>
-						</pathelement>	
+						<pathelement location="{../home}/{@name}"/>
 					</xsl:for-each>
 				</xsl:for-each>
-                                <pathelement>
-                                  <xsl:attribute name="path">
-                                    <xsl:text>${java.class.path}</xsl:text>
-                                  </xsl:attribute>
-                                </pathelement>
+				<pathelement path="${{java.class.path}}"/>
 			</classpath>
 		</java>
 	</xsl:template>
+	
+	
+	<!-- ===========================================================================================
+		Execute a script
+		 =========================================================================================== -->	
 	<xsl:template match="/workspace/project/script">
-		<chmod perm="ugo+rx">
-			<xsl:attribute name="file">
-				<xsl:value-of select="/workspace/@basedir"/>
-				<xsl:text>/</xsl:text>
-				<xsl:value-of select="../@srcdir"/>
-				<xsl:text>/</xsl:text>
-				<xsl:value-of select="@name"/>
-				<xsl:text>.sh</xsl:text>
-			</xsl:attribute>
-		</chmod>
-		<exec>
-			<xsl:attribute name="output">
-				<xsl:value-of select="/workspace/@basedir"/>
-				<xsl:text>/</xsl:text>
-				<xsl:value-of select="../@name"/>
-				<xsl:text>-buildresult.txt</xsl:text>
-			</xsl:attribute>
-			<xsl:attribute name="dir">
-				<xsl:value-of select="/workspace/@basedir"/>
-				<xsl:text>/</xsl:text>
-				<xsl:value-of select="../@srcdir"/>
-			</xsl:attribute>
-			<xsl:attribute name="executable">
-				<xsl:value-of select="/workspace/@basedir"/>
-				<xsl:text>/</xsl:text>
-				<xsl:value-of select="../@srcdir"/>
-				<xsl:text>/</xsl:text>
-				<xsl:value-of select="@name"/>
-				<xsl:text>.sh</xsl:text>
-			</xsl:attribute>
-		</exec>
-	</xsl:template>
+		<xsl:variable name="script.dir" select="concat(/workspace/@basedir, '/', ../@srcdir)"/>
+		<xsl:variable name="script.sh" select="concat($script.dir, '/', ../@name, '.sh')"/>
+		<chmod perm="ugo+rx" file="{$script.sh}"/>
+		<exec dir="{$script.dir}" executable="{$script.sh}"
+			output="{/workspace/@basedir}/{../@name}-buildresult.txt"/>
+	</xsl:template>
+	
+	
+	<!-- ===========================================================================================
+		CVS command for update and checkout
+		@todo the timestamp replace should be done in init ?
+		 =========================================================================================== -->		
 	<xsl:template match="/workspace/project/cvs">
 		<xsl:param name="target"/>
 		<xsl:param name="command"/>
 		<xsl:variable name="repo" select="@repository"/>
+		<xsl:variable name="cvsmodule.present" select="concat('cvsmodule.', ../@name, '.present')"/>
 		<target name="{$target}">
 			<xsl:if test="$target='cvscheckout'">
 				<xsl:attribute name="unless">
-					<xsl:text>cvsmodule.</xsl:text>
-					<xsl:value-of select="../@name"/>
-					<xsl:text>.present</xsl:text>
+					<xsl:value-of select="$cvsmodule.present"/>
 				</xsl:attribute>
 			</xsl:if>
 			<xsl:if test="$target='cvsupdate'">
 				<xsl:attribute name="if">
-					<xsl:text>cvsmodule.</xsl:text>
-					<xsl:value-of select="../@name"/>
-					<xsl:text>.present</xsl:text>
+					<xsl:value-of select="$cvsmodule.present"/>
 				</xsl:attribute>
 			</xsl:if>
-			<replace file="{/workspace/@basedir}/cvs_index.html">
-                                          <xsl:attribute name="token">
-                                            <xsl:text>TAG-</xsl:text>
-                                            <xsl:value-of select="@name"/>
-                                            <xsl:text>-CVS-TIME</xsl:text>
-                                          </xsl:attribute>
-				<xsl:attribute name="value">
-					<xsl:text>${TSTAMP}</xsl:text>
-				</xsl:attribute>
-			</replace>
+			<replace file="{/workspace/@basedir}/cvs_index.html" token="TAG-{../@name}-CVS-TIME" value="${TIMESTAMP}"/>
 			<cvs command="{$command}" quiet="true">
 				<xsl:attribute name="cvsroot">
 					<xsl:value-of select="/workspace/cvs-repository/tree[@name=$repo]/@root"/>
 					<xsl:if test="@dir">
-						<xsl:text>/</xsl:text>
-						<xsl:value-of select="@dir"/>
+						<xsl:value-of select="concat('/', @dir)"/>
 					</xsl:if>
 				</xsl:attribute>
 				<xsl:attribute name="dest">
@@ -260,49 +192,43 @@
 					</xsl:attribute>
 				</xsl:if>
 				<xsl:attribute name="output">
-					<xsl:value-of select="/workspace/@basedir"/>
-					<xsl:text>/</xsl:text>
-					<xsl:value-of select="../@name"/>
-					<xsl:text>-cvsresult.txt</xsl:text>
+					<xsl:value-of select="concat(/workspace/@basedir, '/', ../@name, '-cvsresult.txt')"/>
 				</xsl:attribute>
 			</cvs>
-			<replace file="{/workspace/@basedir}/cvs_index.html">
-                                          <xsl:attribute name="token">
-                                            <xsl:text>TAG-</xsl:text>
-                                            <xsl:value-of select="@name"/>
-                                            <xsl:text>-CVS-STATUS</xsl:text>
-                                          </xsl:attribute>
-				<xsl:attribute name="value">
-					<xsl:text>SUCCESS</xsl:text>
-				</xsl:attribute>
-			</replace>
+			<replace file="{/workspace/@basedir}/cvs_index.html" token="TAG-{../@name}-CVS-STATUS" value="SUCCESS"/>
 		</target>
 	</xsl:template>
+	
+	
+	<!-- ===========================================================================================
+		Check for a dependency availability and immediately call its
+		dependency-check related target.
+		@todo add an additional available check for the jar existence 
+		 =========================================================================================== -->	
 	<xsl:template match="/workspace/project/depend" mode="dependency-check">
 		<xsl:variable name="project" select="@project"/>
 		<xsl:variable name="dependfilename" select="concat(/workspace/@basedir, '/', $project, '.SUCCESS')"/>
 		<available file="{$dependfilename}" property="dependency.{$project}.present"/>
 		<antcall target="{$project}-dependency"/>
 	</xsl:template>
+	
+	
+	<!-- ===========================================================================================
+		Target called only if the related property is not set (ie the dependency
+		is not verified) since it will fail and replace its tag status by a Prereq
+		information in the html index file.
+		 =========================================================================================== -->	
 	<xsl:template match="/workspace/project/depend" mode="failed-dependency">
 		<xsl:variable name="failed-project" select="@project"/>
 		<target name="{$failed-project}-dependency" unless="dependency.{$failed-project}.present">
 			<echo message="PREREQ Failure: Project depends on {$failed-project}"/>
 			<available file="{/workspace/@basedir}/{../@name}.FAILED" property="dependency-failure"/>
-			<replace file="{/workspace/@basedir}/index.html">
-                                          <xsl:attribute name="token">
-                                            <xsl:text>TAG-</xsl:text>
-                                            <xsl:value-of select="@name"/>
-                                            <xsl:text>-STATUS</xsl:text>
-                                          </xsl:attribute>
-				<xsl:attribute name="value">
-					<xsl:text>Prereq Failure: </xsl:text>
-                                        <xsl:value-of select="@project"/>
-				</xsl:attribute>
-			</replace>
-                        <fail message="PREREQ Failure: Dependency on {$failed-project} could not be satisfied."/>
+			<replace file="{/workspace/@basedir}/index.html" token="TAG-{../@name}-STATUS" value="Prereq Failure: {$failed-project}"/>
+			<fail message="PREREQ Failure: Dependency on {$failed-project} could not be satisfied."/>
 		</target>
 	</xsl:template>
+
+
 	<xsl:template match="/workspace/project/ant/property">
 		<arg>
 			<xsl:attribute name="value">
@@ -320,6 +246,7 @@
 								<xsl:value-of select="@project"/>
 								<xsl:text>']/</xsl:text>
 								<xsl:value-of select="@reference"/>
+								
 								<xsl:if test="@id">
 									<xsl:text>[@id='</xsl:text>
 									<xsl:value-of select="@id"/>

The command completed successfully.

