ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Ellsworth <>
Subject Re: How to specify depends as a list of elements, rather than an attribute?
Date Fri, 03 May 2002 23:28:33 GMT

On Friday, May 3, 2002, at 01:01  PM, Diane Holt wrote:

> --- Scott Ellsworth <> wrote:
>> I cannot figure out how to make xslt give me
>> <target name="build-thing" depends="build-subthing1, build-subthing2">
>>   -- other stuff
>> </target>
> I could be wrong (have so far only glanced through my free XSLT 
> book :), but could you use the concat() function?

This is pretty close to what I ended up doing.

For the curious:

   <xsl:template name="make-name-attribute-list">
     <!-- Turns the $elements list into a comma separated string with 
$prefix prepended and $postfix appended to each element. -->
     <xsl:param name="elements"/>
     <xsl:param name="prefix"/>
     <xsl:param name="postfix"/>
     <xsl:for-each select="$elements">
       <xsl:value-of select="concat($prefix,@name,$postfix)" />
       <xsl:if test="position() != last()">, </xsl:if>

   <xsl:template name="concat-with-comma">
     <!-- If either first or second is not null, return the two seperated 
by a comma. -->
     <xsl:param name="first"/>
     <xsl:param name="second"/>
       <xsl:when test="not(boolean(normalize-
space(string($first))))"><xsl:value-of select="$second" /></xsl:when>
       <xsl:when test="not(boolean(normalize-
space(string($second))))"><xsl:value-of select="$first" /></xsl:when>
       <xsl:otherwise><xsl:value-of select="concat($first,', ',$second)" 

       <xsl:for-each select="project">

           <xsl:when test="normalize-space(@build)!='false'">

            <xsl:variable name="build-depend-list">
               <xsl:call-template name="make-name-attribute-list">
                 <xsl:with-param name="elements" 
select="depend[@type='project']" />
                 <xsl:with-param name="prefix" select="'build-'" />

             <xsl:variable name="build-depend-list-with-init">
               <xsl:call-template name="concat-with-comma">
                 <xsl:with-param name="first" select="'init'" />
                 <xsl:with-param name="second" 
select="$build-depend-list" />

             <target name="build-{@name}" 
depends="{$build-depend-list-with-init}" description="Build {@name}">
               <echo message="Building {@name} without dependencies"/>
               <ant dir="{@directory}" target="${{build.buildcommand}}" 

This works great.

I am now trying to make a build-all variable that will have all depends 
with @type='project' that are part of projects with build!= 'false', but 
I am having some problems.  I do not understand why

<xsl:with-param name="elements"
select="project[@build!='false']/depend[@type='project']" />

does not give me the list of depends that I want.


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message