ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scot P. Floess" <flo...@mindspring.com>
Subject Re: Commenting/generate documentation from an ant script
Date Fri, 19 May 2006 16:28:11 GMT
Bill:

Boy do I feel silly now :)  I never considered using XSLT ;)  
Excellent...very much appreciated!

I'll try it out (I hope this weekend).

I really appreciate you quick response!

Scot

bill/wilandra wrote:
> Hi Scot, I use the attached XSL file to generate documentation for my Ant
> files. This is an extension of the XSL stylesheet found at
> http://www-106.ibm.com/developerworks/xml/library/x-antxsl/examples/example2
> /ant2html.xsl modified to pick up some new stuff and to always display the
> documentation attribute and comments. You can put a description attribute on
> the target and macrodef elements. That is where I put my documentation. The
> XSL file will generate an HTML page with a sorted list of targets, macros,
> included files, etc. with appropriate links to the section where the item is
> displayed. It also tries to format the items with some indents. The
> formatting is not always successful but usually close enough for me. This
> only works on a single Ant file so there is no linking to targets in other
> Ant files. I would like to extend it to do that but have no idea how.
>
> It works in Firefox, Opera, and IE. Once in a while I get some glitch in IE
> but since I don't use IE any more I don't worry about it.
>
> HTH Bill 
>
> -----Original Message-----
> From: Scot P. Floess [mailto:floess@mindspring.com] 
> Sent: Friday, May 19, 2006 8:39 AM
> To: Ant Users List
> Subject: Commenting/generate documentation from an ant script
>
> I have what may be either a stupid questions or a silly ones...but I can't
> find an answer (perhaps my google search is using the wrong key words)...
>
> As part of one of my open source projects I am working on some (I hope)
> reusable Ant scripts.  I have some macro definitions, etc.  I was wondering
> if there is any standard out there on how one should document macros?  Sorta
> like javadoc notation or some "preferred" way of internal documentation.
>
> Another question, is there a tool to generate java-doc like HTML against Ant
> scripts?  Or does one need to handcraft their own web pages?
>
> Final question (wow it just keeps going):  what about unit test cases for
> one's Ant scripts.  For instance, supposing one writes macros - what do
> people do for unit test cases?  Presently, I have a script file that imports
> the macro scripts file and calls out to the macros...then I evaluate
> properties, etc for accuracy.  However, I was wondering if there is some
> "preferred" mechanism as well...
>
> Thanks again :)
>
> Scot
>
> --
> Scot P. Floess
> 27 Lake Royale
> Louisburg, NC  27549
>
> 252-478-8087 (Home)
> 919-754-4592 (Work)
>
> Chief Architect JPlate  http://sourceforge.net/projects/jplate
> Chief Architect JavaPIM http://sourceforge.net/projects/javapim
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional
> commands, e-mail: user-help@ant.apache.org
>
>
>   
> ------------------------------------------------------------------------
>
> <?xml version="1.0" encoding="UTF-8"?>
> 	<!--
> 		Copyright (C) 2004-2005, Wilandra Consulting LLC. All rights reserved.
>
> 		This is an extension of the XSL stylesheet found at http://www-106.ibm.com/developerworks/xml/library/x-antxsl/examples/example2/ant2html.xsl.
>
> 		The extensions include:
> 			display macrodef elements
> 			display the project description element
> 			display if/unless on targets
> 			display imports
> 			toc items are only shown if there are items to display
> 			items in the main body are only shown if there are items to display
>
> 		There are also minor changes in formatting and style.
>
> 		There are still some minor problems with formatting of the target and macro code lines.
Indents sometimes don't work correctly.
>
> 		This has been tested on Windows XP Professional with Mozilla 1.7.1 and IE 6.0.
>
> 		Disclaimer
> 			Wilandra Consulting LLC provides no guarantee that these files will be useful for
your purpose. If you experience any problems using any part of this tool you may report them
to Bill Rich (bill@wilandra.com). We will determine if a change is warranted and may or may
not make the change. This service is provided on a time available basis and no service level
commitment is made.
>
> 		For more information about our services please visit us at www.Wilandra.com.
>
> 		License Agreement
> 			Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
> 			1. Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
> 			2. Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.
> 			3. All advertising materials mentioning features or use of this software must display
the following acknowledgment:
> 				This product includes software developed by Wilandra Consulting LLC (www.Wilandra.com)
and/or its contributors.
> 			4. Neither the name of Wilandra Consulting LLC or its contributors may be used to
endorse or promote products derived from this software without specific written permission.
>
> 		THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> 	-->
> 	<!-- version 2005/06/20 -->
> 	<!-- author Bill Rich, bill@wilandra.com, Wilandra Consulting LLC. Copyright (C)
2004-2005, Wilandra Consulting LLC. All rights reserved. -->
>
> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output method="html" indent="no" omit-xml-declaration="yes" encoding="UTF-8"/>
>
> <xsl:template match="/">
> 	<html>
> 		<xsl:comment>XSLT stylesheet used to transform this file:	wfrant2html.xsl</xsl:comment>
> 		<xsl:apply-templates select="project"/>
> 	</html>
> </xsl:template>
>
> <xsl:template match="project">
> 	<head>
> 	<title>Ant Project Source: <xsl:value-of select="@name"/></title>
> 	</head>
> 	<body bgcolor="#ffffff" marginheight="2" marginwidth="2" topmargin="2" leftmargin="2">
> 		<table border="1" cellspacing="0" cellpadding="2" clear="all">
> 			<tr>
> 				<!-- Generate the Table of Contents in the left most cell of the main table. -->
> 				<td valign="TOP" width="20%">
> 					<h3><a name="toc">Table of Contents</a></h3>
> 					<h3><a href="#project">Project Attributes</a></h3>
> 					<!-- The imported files section. -->
> 					<xsl:if test="count(./import) > 0">
> 						<h3><a href="#imports">Imported Files</a></h3>
> 					</xsl:if>
> 					<!-- A list of Properties -->
> 					<xsl:if test="count(./property) > 0">
> 						<h3><a href="#properties">Properties</a></h3>
> 						<ul>
> 							<xsl:for-each select="./property/@name">
> 								<xsl:sort/>
> 								<xsl:variable name="propName" select="."/>
> 								<xsl:text disable-output-escaping="yes">	 </xsl:text>
> 								<xsl:element name="li">
> 									<xsl:element name="a">
> 										<xsl:attribute name="href">
> 											<xsl:value-of select="concat('#property-',$propName)"/>
> 										</xsl:attribute>
> 										<xsl:value-of select="$propName"/>
> 									</xsl:element>
> 								</xsl:element>
> 							</xsl:for-each>
> 						</ul>
> 					</xsl:if>
> 					<!-- A list of Targets -->
> 					<xsl:if test="count(./target) > 0">
> 						<a name="toc-targets"/>
> 						<h3><a href="#targets">Targets</a></h3>
> 						<ul>
> 							<xsl:for-each select="./target">
> 								<xsl:sort select="@name"/>
> 								<xsl:variable name="tarName" select="@name"/>
> 								<xsl:text disable-output-escaping="yes">	 </xsl:text>
> 								<xsl:element name="li">
> 									<xsl:element name="a">
> 										<xsl:attribute name="href">
> 											<xsl:value-of select="concat('#target-',$tarName)"/>
> 										</xsl:attribute>
> 										<xsl:value-of select="$tarName"/>
> 									</xsl:element>
> 								</xsl:element>
> 							</xsl:for-each>
> 						</ul>
> 					</xsl:if>
> 					<!-- A list of Macros -->
> 					<xsl:if test="count(./macrodef) > 0">
> 						<a name="toc-macros"/>
> 						<h3><a href="#macros">Macros</a></h3>
> 						<ul>
> 							<xsl:for-each select="./macrodef">
> 								<xsl:sort select="@name"/>
> 								<xsl:variable name="macName" select="@name"/>
> 								<xsl:text disable-output-escaping="yes">	 </xsl:text>
> 								<xsl:element name="li">
> 									<xsl:element name="a">
> 										<xsl:attribute name="href">
> 											<xsl:value-of select="concat('#macro-',$macName)"/>
> 										</xsl:attribute>
> 										<xsl:value-of select="$macName"/>
> 									</xsl:element>
> 								</xsl:element>
> 							</xsl:for-each>
> 						</ul>
> 					</xsl:if>
> 				</td>
> 				<!-- End of Table of Contents -->
>
> 				<!-- Fill in the main part of the table with project information. -->
> 				<td valign="TOP" width="80%">
> 					<!-- Begin project data -->
> 					<table border="0" cellspacing="0" cellpadding="5" clear="all">
> 						<tr>
> 							<td colspan="3">
> 								<a name="project"/>
> 								<h3>Project Information</h3>
> 							</td>
> 						</tr>
> 						<tr>
> 							<td width="5%"/>
> 							<td valign="TOP" width="25%">
> 								<b>Name:</b>
> 							</td>
> 							<td valign="TOP" width="70%">
> 								<xsl:value-of select="@name"/>
> 							</td>
> 						</tr>
> 						<tr>
> 							<td width="5%"/>
> 							<td valign="TOP" width="25%">
> 								<b>Base directory:</b>
> 							</td>
> 							<td valign="TOP" width="70%">
> 								<xsl:choose>
> 									<xsl:when test="@basedir='.'">
> 										<i>current-working-directory</i>
> 									</xsl:when>
> 									<xsl:otherwise>
> 										<xsl:value-of select="@basedir"/>
> 									</xsl:otherwise>
> 								</xsl:choose>
> 							</td>
> 						</tr>
> 						<tr>
> 							<td width="5%"/>
> 							<td valign="TOP" width="25%">
> 								<b>Default target:</b>
> 							</td>
> 							<td valign="TOP" width="70%">
> 								<xsl:call-template name="formatTargetList">
> 									<xsl:with-param name="targets" select="@default"/>
> 								</xsl:call-template>
> 							</td>
> 						</tr>
> 						<tr>
> 							<td width="5%"/>
> 							<td valign="TOP" width="25%">
> 								<b>Description:</b>
> 							</td>
> 							<td valign="TOP" width="70%">
> 								<xsl:value-of select="."/>
> 							</td>
> 						</tr>
> 					</table>
>
> 					<!-- Begin import data -->
> 					<xsl:if test="count(./import) > 0">
> 						<hr/>
> 						<table border="0" cellspacing="0" cellpadding="5" clear="all">
> 							<tr>
> 								<td colspan="2">
> 									<a name="imports"/>
> 									<h3><a href="#toc">Imported Files</a></h3>
> 								</td>
> 							</tr>
> 							<xsl:variable name="importList" select="/project/import"/>
> 							<xsl:for-each select="/project/import/@file">
> 								<tr>
> 									<td width="5%"/>
> 									<td valign="TOP" width="75%">
> 										<xsl:element name="a">
> 											<xsl:attribute name="file">
> 												<xsl:text>import-</xsl:text><xsl:value-of select="."/>
> 											</xsl:attribute>
> 										</xsl:element>
> 										<xsl:value-of select="."/>
> 									</td>
> 								</tr>
> 							</xsl:for-each>
> 						</table>
> 					</xsl:if>
>
> 					<!-- Begin project properties data -->
> 					<xsl:if test="count(./property) > 0">
> 						<hr/>
> 						<table border="0" cellspacing="0" cellpadding="5" clear="all">
> 							<tr>
> 								<td colspan="3">
> 									<a name="properties"/>
> 									<h3><a href="#toc">Project Properties</a></h3>
> 								</td>
> 							</tr>
> 							<xsl:for-each select="./property/@name">
> 								<xsl:sort/>
> 								<tr>
> 									<td width="5%"/>
> 									<td valign="TOP" width="25%">
> 										<xsl:element name="a">
> 											<xsl:attribute name="name">
> 												<xsl:text>property-</xsl:text><xsl:value-of select="."/>
> 											</xsl:attribute>
> 										</xsl:element>
> 										<b><xsl:value-of select="."/></b>
> 									</td>
> 									<td valign="TOP" width="70%">
> 										<xsl:choose>
> 											<xsl:when test="count(../@location) > 0">
> 												<xsl:value-of select="../@location"/>
> 											</xsl:when>
> 											<xsl:when test="count(../@value) > 0">
> 												<xsl:value-of select="../@value"/>
> 											</xsl:when>
> 										</xsl:choose>
> 									</td>
> 								</tr>
> 							</xsl:for-each>
> 						</table>
> 					</xsl:if>
>
> 					<!-- Begin targets data -->
> 					<xsl:if test="count(./target) > 0">
> 						<hr/>
> 						<table border="0" cellspacing="0" cellpadding="5" clear="all">
> 							<tr>
> 								<td colspan="3">
> 									<a name="targets"/>
> 									<h3><a href="#toc">Targets</a></h3>
> 								</td>
> 							</tr>
> 							<xsl:for-each select="./target">
> 								<xsl:sort select="@name"/>
> 								<tr>
> 									<td width="5%"/>
> 									<td valign="TOP" width="25%">
> 										<xsl:element name="a">
> 											<xsl:attribute name="name">
> 												<xsl:text>target-</xsl:text><xsl:value-of select="@name"/>
> 											</xsl:attribute>
> 										</xsl:element>
> 										<b>Target:</b>
> 									</td>
> 									<td valign="TOP" width="70%">
> 										<xsl:value-of select="@name"/>
> 									</td>
> 								</tr>
> 								<xsl:if test="count(./@description) > 0">
> 									<tr>
> 										<td width="5%"/>
> 										<td valign="TOP" width="25%">
> 											<b>Description:</b>
> 										</td>
> 										<td valign="TOP" width="70%">
> 											<xsl:value-of select="@description"/>
> 										</td>
> 									</tr>
> 								</xsl:if>
> 								<xsl:if test="count(./@depends) > 0">
> 									<tr>
> 										<td width="5%"/>
> 										<td valign="TOP" width="25%">
> 											<b>Dependencies:</b>
> 										</td>
> 										<td valign="TOP" width="70%">
> 											<xsl:call-template name="formatTargetList">
> 												<xsl:with-param name="targets" select="@depends"/>
> 											</xsl:call-template>
> 										</td>
> 									</tr>
> 								</xsl:if>
> 								<!-- wfr - Add supoort for if/unless on targets. -->
> 								<xsl:if test="count(./@if) > 0">
> 									<tr>
> 										<td width="5%"/>
> 										<td valign="TOP" width="25%">
> 											<b>Run If:</b>
> 										</td>
> 										<td valign="TOP" width="70%">
> 											<xsl:call-template name="formatNameList">
> 												<xsl:with-param name="names" select="@if"/>
> 											</xsl:call-template>
> 										</td>
> 									</tr>
> 								</xsl:if>
> 								<xsl:if test="count(./@unless) > 0">
> 									<tr>
> 										<td width="5%"/>
> 										<td valign="TOP" width="25%">
> 											<b>Run Unless:</b>
> 										</td>
> 										<td valign="TOP" width="70%">
> 											<xsl:call-template name="formatNameList">
> 												<xsl:with-param name="names" select="@unless"/>
> 											</xsl:call-template>
> 										</td>
> 									</tr>
> 								</xsl:if>
> 								<!-- wfr end - Add supoort for if/unless on targets. -->
> 								<tr>
> 									<td width="5%"/>
> 									<td valign="TOP" width="25%">
> 										<b>Tasks:</b>
> 									</td>
> 									<td valign="TOP" width="70%">
> 										<xsl:choose>
> 											<xsl:when test="count(child::node()) > 0">
> 												<xsl:apply-templates select="child::node()"/>
> 											</xsl:when>
> 											<xsl:otherwise>
> 												<xsl:text>None</xsl:text>
> 											</xsl:otherwise>
> 										</xsl:choose>
> 									</td>
> 								</tr>
> 								<tr>
> 									<td colspan="3">
> 										<xsl:element name="a">
> 											<xsl:attribute name="href">
> 												<xsl:text>#toc-targets</xsl:text>
> 											</xsl:attribute>
> 											<font size="-1"><xsl:text>Return to targets</xsl:text></font>
> 										</xsl:element>
> 									</td>
> 								</tr>
> 								<tr>
> 									<td colspan="3">
> 										<xsl:element name="a">
> 											<xsl:attribute name="href">
> 												<xsl:text>#toc</xsl:text>
> 											</xsl:attribute>
> 											<font size="-1"><xsl:text>Return to table of contents</xsl:text></font>
> 										</xsl:element>
> 									</td>
> 								</tr>
> 								<xsl:if test="position() &lt; last()">
> 									<tr><td colspan="3"><hr/></td></tr>
> 								</xsl:if>
> 							</xsl:for-each>
> 						</table>
> 					</xsl:if>
>
> 					<!-- Begin macro data -->
> 					<xsl:if test="count(./macrodef) > 0">
> 						<hr/>
> 						<table border="0" cellspacing="0" cellpadding="5" width="100%">
> 							<tr>
> 								<td colspan="3">
> 									<a name="macros"/>
> 									<h3><a href="#toc">Macros</a></h3>
> 								</td>
> 							</tr>
> 							<xsl:for-each select="./macrodef">
> 								<xsl:sort select="@name"/>
> 								<tr>
> 									<td width="5%"/>
> 									<td valign="BOTTOM" width="25%">
> 										<xsl:element name="a">
> 											<xsl:attribute name="name">
> 												<xsl:text>macro-</xsl:text><xsl:value-of select="@name"/>
> 											</xsl:attribute>
> 										</xsl:element>
> 										<b>Macro:</b>
> 									</td>
> 									<td valign="BOTTOM" width="70%">
> 										<xsl:value-of select="@name"/>
> 									</td>
> 								</tr>
> 								<xsl:if test="count(./@description) > 0">
> 									<tr>
> 										<td width="5%"/>
> 										<td valign="TOP" width="25%">
> 											<b>Description:</b>
> 										</td>
> 										<td valign="TOP" width="70%">
> 											<xsl:value-of select="@description"/>
> 										</td>
> 									</tr>
> 								</xsl:if>
> 								<tr>
> 									<td width="5%"/>
> 									<td valign="TOP" width="25%">
> 										<b>Tasks:</b>
> 									</td>
> 									<td valign="TOP" width="70%">
> 										<xsl:choose>
> 											<xsl:when test="count(child::*) > 0">
> 												<xsl:apply-templates select="child::node()"/>
> 											</xsl:when>
> 											<xsl:otherwise>
> 												<xsl:text>None</xsl:text>
> 											</xsl:otherwise>
> 										</xsl:choose>
> 									</td>
> 								</tr>
> 								<tr>
> 									<td colspan="3">
> 										<xsl:element name="a">
> 											<xsl:attribute name="href">
> 												<xsl:text>#toc-macros</xsl:text>
> 											</xsl:attribute>
> 											<font size="-1"><xsl:text>Return to macros</xsl:text></font>
> 										</xsl:element>
> 									</td>
> 								</tr>
> 								<tr>
> 									<td colspan="3">
> 										<xsl:element name="a">
> 											<xsl:attribute name="href">
> 												<xsl:text>#toc</xsl:text>
> 											</xsl:attribute>
> 											<font size="-1"><xsl:text>Return to table of contents</xsl:text></font>
> 										</xsl:element>
> 									</td>
> 								</tr>
> 								<xsl:if test="position() &lt; last()">
> 									<tr><td colspan="3"><hr/></td></tr>
> 								</xsl:if>
> 							</xsl:for-each>
> 						</table>
> 					</xsl:if>
> 				</td>
> 			</tr>
> 		</table>
> 	</body>
> </xsl:template>
>
> 	<!--
> 		=========================================================================
> 			Purpose:	Copy each node and attribute, exactly as found, to the output
> 								tree.
> 		=========================================================================
> 	-->
> 	<!-- xsl:template match="node()" name="writeTask">
> 		<xsl:param		name="indent"	 select="string('')"/>
> 		<xsl:variable name="nodeName" select="name(.)"/>
> <pre><xsl:value-of select="$indent"/>&lt;*****<xsl:value-of select="$nodeName"/>
> 			<xsl:if test="count(@*) > 0">
> 				<xsl:for-each select="@*">
> 					<xsl:if test="position() > 1"><xsl:value-of select="'&#10;'"/></xsl:if>
> 					<xsl:value-of select="concat('		 ', $indent, name(),'=&quot;',.,'&quot;')"/>
> 					<xsl:if test="position() = last()">
> 						<xsl:choose>
> 							<xsl:when test="count(../*) > 0">*****&gt;</xsl:when>
> 							<xsl:otherwise>/&gt;</xsl:otherwise>
> 						</xsl:choose>
> 					</xsl:if>
> 				</xsl:for-each>
> 			</xsl:if>
>
> 			<xsl:for-each select="child::node()">
> 				<xsl:call-template name="writeTask">
> 					<xsl:with-param name="indent" select="concat($indent, '	')"/>
> 				</xsl:call-template>
> 			</xsl:for-each>
>
> <xsl:value-of select="$indent"/><xsl:if test="count(child::node()) > 0">&lt;/<xsl:value-of
select="$nodeName"/>&gt;</xsl:if></pre>
>
> 	</xsl:template -->
> 	<!--
> 		=========================================================================
> 			Purpose:	Copy each node and attribute, exactly as found, to the output
> 								tree.
> 		=========================================================================
> 	-->
> 	<xsl:template match="node()" name="writeTask">
> 		<xsl:param		name="indent"	 select="string('&#160;')"/>
> 		<xsl:variable name="nodeName" select="name(.)"/>
>
> 		<xsl:if test="not($nodeName = '')">
> 			<code>
> 			<xsl:value-of select="$indent"/>&lt;<xsl:value-of select="$nodeName"/>
> 			<xsl:choose>
> 				<xsl:when test="count(@*) > 0">
> 					<xsl:for-each select="@*">
>
> 						<xsl:choose>
> 							<xsl:when test="position() = 1">
> 								<xsl:value-of select="concat('&#160;', name(),'=&quot;')"/>
> 							</xsl:when>
> 							<xsl:otherwise>
> 								<br/>
> 								<!-- xsl:value-of select="concat(translate(name(..), name(..), '									
 '), '&#160;&#160;', $indent, name(), '=&quot;')"/ -->
> 								<xsl:value-of select="concat(translate(name(..), name(..), '&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;'),
'&#160;&#160;', $indent, name(), '=&quot;')"/>
> 							</xsl:otherwise>
> 						</xsl:choose>
>
> 						<xsl:call-template name="formatTaskAttributeValue">
> 							<xsl:with-param name="value" select="."/>
> 						</xsl:call-template>
> 						<xsl:value-of select="'&quot;'"/>
>
> 						<xsl:if test="position() = last()">
> 							<xsl:choose>
> 								<xsl:when test="count(../*) > 0">&gt;<br/></xsl:when>
> 								<xsl:otherwise>/&gt;<br/></xsl:otherwise>
> 							</xsl:choose>
> 						</xsl:if>
> 					</xsl:for-each>
> 				</xsl:when>
> 				<xsl:otherwise>&gt;<br/></xsl:otherwise>
> 			</xsl:choose>
>
> 			<xsl:for-each select="child::node()">
> 				<xsl:call-template name="writeTask">
> 					<xsl:with-param name="indent" select="concat($indent, '&#160;')"/>
> 				</xsl:call-template>
> 			</xsl:for-each>
>
> 			<xsl:value-of select="$indent"/>
> 			<xsl:if test="count(child::node()) > 0">
> 				&lt;/<xsl:value-of select="$nodeName"/>&gt;<br/>
> 			</xsl:if>
> 			</code>
>
> 		</xsl:if>
> 	</xsl:template>
>
> 	<!--
> 		=========================================================================
> 			Purpose:	Format a task attribute's value.
> 		=========================================================================
> 	-->
> 	<xsl:template name="formatTaskAttributeValue">
> 		<xsl:param		name="value"/>
>
> 		<xsl:variable name="propertyList" select="/project/property"/>
>
> 		<xsl:variable name="expandedValue">
> 			<xsl:call-template name="expandProperty">
> 				<xsl:with-param name="list"	select="$propertyList"/>
> 				<xsl:with-param name="value" select="$value"/>
> 			</xsl:call-template>
> 		</xsl:variable>
>
> 		<xsl:choose>
> 			<xsl:when test="contains($value, '${')">
> 				<xsl:variable name="squote">'</xsl:variable>
> 				<xsl:element name="ins">
> 					<xsl:attribute name="onMouseOver">
> 						javascript:window.status='<xsl:value-of select="$value"/>'
> 					</xsl:attribute>
> 					<xsl:value-of select="$expandedValue"/>
> 				</xsl:element>
> 			</xsl:when>
>
> 			<xsl:otherwise>
> 				<xsl:value-of select="$expandedValue"/>
> 			</xsl:otherwise>
> 		</xsl:choose>
>
> 	</xsl:template>
>
> 	<!--
> 		=========================================================================
> 			Purpose:	Expand an Ant property.
> 		=========================================================================
> 	-->
> 	<xsl:template name="expandProperty">
> 		<xsl:param		name="list"/>
> 		<xsl:param		name="value"/>
>
> 		<xsl:choose>
> 			<xsl:when test="contains($value, '${')">
> 				<xsl:variable name="first" select="normalize-space(substring-before($value,'${'))"/>
> 				<xsl:variable name="temp"	select="normalize-space(substring-after($value,'${'))"/>
> 				<xsl:variable name="pname" select="normalize-space(substring-before($temp,'}'))"/>
> 				<xsl:variable name="rest"	select="normalize-space(substring-after($temp,'}'))"/>
>
> 				<xsl:value-of select="$first"/>
>
> 				<xsl:if test="not($pname = '')">
> 					<xsl:variable name="prop" select="$list[@name=$pname]"/>
> 					<xsl:choose>
> 						<xsl:when test="$pname='basedir'">
> 							<xsl:value-of select="/project/@basedir"/>
>
> 							<xsl:call-template name="expandProperty">
> 								<xsl:with-param name="list"	select="$list"/>
> 								<xsl:with-param name="value" select="$rest"/>
> 							</xsl:call-template>
> 						</xsl:when>
>
> 						<xsl:when test="count($prop) > 0">
> 							<xsl:variable name="pvalue">
> 								<xsl:choose>
> 									<xsl:when test="count($prop/@location) > 0">
> 										<xsl:value-of select="$prop/@location"/>
> 									</xsl:when>
>
> 									<xsl:when test="count($prop/@value) > 0">
> 										<xsl:value-of select="$prop/@value"/>
> 									</xsl:when>
> 								</xsl:choose>
> 							</xsl:variable>
>
> 							<xsl:call-template name="expandProperty">
> 								<xsl:with-param name="list"	select="$list"/>
> 								<xsl:with-param name="value" select="$pvalue"/>
> 							</xsl:call-template>
> 						</xsl:when>
>
> 						<xsl:otherwise>
> 							<xsl:value-of select="concat('${', $pname, '}')"/>
> 						</xsl:otherwise>
> 					</xsl:choose>
>
> 					<xsl:call-template name="expandProperty">
> 						<xsl:with-param name="list"	select="$list"/>
> 						<xsl:with-param name="value" select="$rest"/>
> 					</xsl:call-template>
> 				</xsl:if>
> 			</xsl:when>
>
> 			<xsl:otherwise>
> 				<xsl:value-of select="$value"/>
> 			</xsl:otherwise>
> 		</xsl:choose>
> 	</xsl:template>
>
> 	<!--
> 		=========================================================================
> 			Purpose:	Ignore comments imbedded into the text.
> 		=========================================================================
> 	-->
> 	<!-- xsl:template match="comment()"/ -->
> 	<xsl:template match="comment()" name="formatComment">
> 		<code>&lt;!-- <xsl:value-of select="."/> --&gt;</code><br/>
> 	</xsl:template>
>
> 	<!--
> 		=========================================================================
> 			Purpose:	Format a list of target names as references.
> 		=========================================================================
> 	-->
> 	<xsl:template name="formatTargetList">
> 		<xsl:param		name="targets" select="string('')"/>
>
> 		<xsl:variable name="list"		select="normalize-space($targets)"/>
> 		<xsl:variable name="first"	 select="normalize-space(substring-before($targets,','))"/>
> 		<xsl:variable name="rest"		select="normalize-space(substring-after($targets,','))"/>
>
> 		<xsl:if test="not($list = '')">
> 			<xsl:choose>
> 				<xsl:when test="contains($list, ',')">
> 					<xsl:element name="a">
> 						<xsl:attribute name="href">
> 							<xsl:value-of select="concat('#target-', $first)"/>
> 						</xsl:attribute>
> 						<xsl:value-of select="$first"/>
> 					</xsl:element>
>
> 					<xsl:text>, </xsl:text>
>
> 					<xsl:call-template name="formatTargetList">
> 						<xsl:with-param name="targets" select="$rest"/>
> 					</xsl:call-template>
> 				</xsl:when>
>
> 				<xsl:otherwise>
> 					<xsl:element name="a">
> 						<xsl:attribute name="href">
> 							<xsl:value-of select="concat('#target-', $list)"/>
> 						</xsl:attribute>
> 						<xsl:value-of select="$list"/>
> 					</xsl:element>
> 				</xsl:otherwise>
> 			</xsl:choose>
> 		</xsl:if>
> 	</xsl:template>
>
> 	<!-- wfr - Add a section to format a list of names that are not links.	Used in the
if/unless section.
> 		=========================================================================
> 			Purpose:	Format a list of names.
> 		=========================================================================
> 	-->
> 	<xsl:template name="formatNameList">
> 		<xsl:param		name="names" select="string('')"/>
>
> 		<xsl:variable name="list"		select="normalize-space($names)"/>
> 		<xsl:variable name="first"	 select="normalize-space(substring-before($names,','))"/>
> 		<xsl:variable name="rest"		select="normalize-space(substring-after($names,','))"/>
>
> 		<xsl:if test="not($list = '')">
> 			<xsl:choose>
> 				<xsl:when test="contains($list, ',')">
> 							<xsl:value-of select="$first"/>
>
> 					<xsl:text>, </xsl:text>
>
> 					<xsl:call-template name="formatNameList">
> 						<xsl:with-param name="names" select="$rest"/>
> 					</xsl:call-template>
> 				</xsl:when>
>
> 				<xsl:otherwise>
> 						 <xsl:value-of select="$list"/>
> 				</xsl:otherwise>
> 			</xsl:choose>
> 		</xsl:if>
> 	</xsl:template>
> 	<!-- wfr end - Add a section to format a list of names that are not links.	Used in
the if/unless section. -->
>
> </xsl:stylesheet>
>   

-- 
Scot P. Floess
27 Lake Royale
Louisburg, NC  27549

252-478-8087 (Home)
919-754-4592 (Work)

Chief Architect JPlate  http://sourceforge.net/projects/jplate
Chief Architect JavaPIM http://sourceforge.net/projects/javapim


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message