xsl-list
[Top] [All Lists]

RE: [xsl] Removing dead targets from Ant build files

2007-12-21 02:06:51
Hi Graham and all other xsl-list contributors,

To only remove targets not listed in depends attributes (or project
default attribute), 
it looks something like this (xsl 1.0):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
        exclude-result-prefixes="xsl">
<xsl:output method="xml" indent="yes" encoding="utf-8"/>
<xsl:template match="/project">
  <xsl:copy>
    <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>
<xsl:template match="target">
  <xsl:variable name="name" select="@name"/>
  <xsl:if test="//target[contains(@depends,$name)] or
/project[(_at_)default=$name]">
    <xsl:copy-of select="."/>
  </xsl:if>
</xsl:template>
</xsl:stylesheet>

I tested it with some very simple ant build files, using the msxsl
processor.
This will remove any target that is not listed in either
/project/@default or any //target/@depends.
IIRC ant complains if some target/@depends contains a non existing
target, 
so I didn't bother cleaning up the target/@depends.

Breaking up large build files into smaller ones is something completely
different. 
I would do that in XSLT 2.0 anyway using xsl:result-document.

Regards,
Peter 

-----Original Message-----
From: Heath, Graham [mailto:Graham(_dot_)Heath(_at_)fujitsu-siemens(_dot_)com] 
Sent: vrijdag 21 december 2007 8:45
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Removing dead targets from Ant build files


Does anyone out there have a stylesheet that parses and trims 
dead targets from ant build files?

I started writing a stylesheet to do this but it got very 
convoluted and never acheived what I wanted so I gave up.
Currently we use Saxon 6.53 (becuase of DocBook).
I am also convinced that other people must also have large 
unwieldy ant files that over time have collected a bunch of 
dead targets (ones that do not appear in depends="" lists and 
do not have a description attribute).

Thanks for any ideas, hints, or stylesheets. There is, of 
course, the related issue of chunking these build files by 
following dependancies from distinct targets to build 
"feature" related build files, that are smaller and more manageable.


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--







This e-mail and any attachment is for authorised use by the intended 
recipient(s) only. It may contain proprietary material, confidential 
information and/or be subject to legal privilege. It should not be copied, 
disclosed to, retained or used by, any other party. If you are not an intended 
recipient then please promptly delete this e-mail and any attachment and all 
copies and inform the sender. Thank you.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>