You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Stefan Kost <s....@webmacher.de> on 2002/06/05 10:50:04 UTC

xsl script to generate graphical representation of build.xml

hi,

attached you find a xsl script, which generates a .dot out of a
build.xml file. The dot file can be rendered using the dot command (from
the graphviz package, see http://www.graphviz.org/) to lots of formats
like ps or png.
Minimal instructions are in the xsl file.

Stefan
-- 

 < W E B M A C H E R > 
EDV+INTERNETSERVICE GMBH

POST: August Bebel Str. 69
      04275 Leipzig

FON:  +49 341 30 34 833
FAX:  +49 341 30 34 840
WEB:  www.webmacher.de

Re: xsl script to generate graphical representation of build.xml

Posted by Stefan Kost <s....@webmacher.de>.
Hi 
> Eager to see what this thing could do with my build files, I *gasp* read the
> docs and found exactly what I needed.  Attached is a slightly modified
> version of Stefan's original XSL file - all I did was enclose all the node
> names with double quotes.
> 
> Let me know if you want this contributed to Ant's CVS.  This would even make
> a handy custom Ant task, to wrap calling dot.exe - although I'll get by with
> <xslt> and <exec> for now.
>
Many thanks to Erik and Nascif for all modifications. And yes, it would
be great to have this in CVS.
Anyway, at the moment I am fine with calling it via xslt and exec too. I
use it on the server where I do nightly checkout, build,
javadocgeneration, cvs stats and so on.

Stefan
> 
> Very nice, Stefan.
> 
> Thanks,
>     Erik
> 
> ----- Original Message -----
> From: "Erik Hatcher" <ja...@ehatchersolutions.com>
> To: "Ant Users List" <an...@jakarta.apache.org>
> Sent: Wednesday, June 05, 2002 7:58 PM
> Subject: Re: xsl script to generate graphical representation of build.xml
> 
> 
> > This looks pretty slick.  I tried it out and got this while running 'dot'
> >
> > graph parser: syntax error near line 18
> > context:    >>>  do- <<< common [label="do-common\n"];
> >
> > Looks like it doesn't like dashes in target names.  Is there a way to have
> > them escaped in the .dot files?  Would you modify it so that it could work
> > in such cases?  It still generated a .png, but it looked incomplete.
> >
> > Many thanks for this contribution.  Would you mind this being committed to
> > Ant's CVS for inclusion into Ant 1.6?  If so, let me know.
> >
> >     Erik
> >
> > ----- Original Message -----
> > From: "Stefan Kost" <s....@webmacher.de>
> > To: "Ant Users List" <an...@jakarta.apache.org>
> > Cc: <an...@jakarta.apache.org>
> > Sent: Wednesday, June 05, 2002 4:50 AM
> > Subject: xsl script to generate graphical representation of build.xml
> >
> >
> > > hi,
> > >
> > > attached you find a xsl script, which generates a .dot out of a
> > > build.xml file. The dot file can be rendered using the dot command (from
> > > the graphviz package, see http://www.graphviz.org/) to lots of formats
> > > like ps or png.
> > > Minimal instructions are in the xsl file.
> > >
> > > Stefan
> > > --
> > >
> > >  < W E B M A C H E R >
> > > EDV+INTERNETSERVICE GMBH
> > >
> > > POST: August Bebel Str. 69
> > >       04275 Leipzig
> > >
> > > FON:  +49 341 30 34 833
> > > FAX:  +49 341 30 34 840
> > > WEB:  www.webmacher.de
> > >
> >
> >
> > --------------------------------------------------------------------------
> --
> > ----
> >
> >
> > > --
> > > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
> > --
> > To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> > For additional commands, e-mail: <ma...@jakarta.apache.org>
> >
> >
> ----
> 

> <?xml version="1.0"?>
> <!-- ant2dot.xsl 0.1 (C) by Stefan Kost <en...@sonicpulse.de> (05.July.2002) -->
> <!--
> to compile do
>   setenv LANG=POSIX   (needed for CVS version of xalan/xerces)
>   java -cp ~/lib/xalan.jar:~/lib/xerces.jar org.apache.xalan.xslt.Process -XSL ant2dot.xsl -IN build.xml -OUT build.dot
>   dot -Tps build.dot -obuild.ps
>   dot -Tpng build.dot -obuild.png
> -->
> <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> 
> 	<xsl:output method="text"/>
> 
> 	<xsl:template match="/project">
> digraph project {
> 	node [shape=box,fontname="Arial",fontsize="10"];
> 	edge [fontname="Arial",fontsize="8"];
> 	rankdir=LR;
> 	<xsl:apply-templates/>
> }
> 	</xsl:template>
> 
> 	<xsl:template match="/project/target">
> 		"<xsl:value-of select="@name"/>" [label="<xsl:value-of select="@name"/>\n<xsl:value-of select="@description"/>"];
> 		<xsl:variable name="target" select="@name"/>
> 		<xsl:variable name="depends" select="@depends"/>
> 		<xsl:if test="$depends!=''">
> 			<xsl:call-template name="split-depends">
> 				<xsl:with-param name="depends" select="$depends"/>
> 				<xsl:with-param name="target" select="$target"/>
> 			</xsl:call-template>
> 		</xsl:if>
> 	</xsl:template>
> 	
> 	<xsl:template name="split-depends">
> 		<xsl:param name="depends"/>
> 		<xsl:param name="target"/>
> 		<xsl:choose>
> 			<xsl:when test="contains($depends,',')">
> 				<xsl:variable name="dependsCur" select="normalize-space(substring-before($depends, ','))"/>
> 				<xsl:variable name="dependsNext" select="normalize-space(substring-after($depends, ','))"/>
> 				"<xsl:value-of select="$dependsCur"/>" -&gt; "<xsl:value-of select="$target"/>";
> 				<xsl:call-template name="split-depends">
> 					<xsl:with-param name="depends" select="$dependsNext"/>
> 					<xsl:with-param name="target" select="$target"/>
> 				</xsl:call-template>
> 			</xsl:when>
> 			<xsl:otherwise>
> 				"<xsl:value-of select="$depends"/>" -&gt; "<xsl:value-of select="$target"/>";
> 			</xsl:otherwise>
> 		</xsl:choose>
> 	</xsl:template>
> 	
> </xsl:transform>
> 
> 
> 
> ----
> 

> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
-- 

 < W E B M A C H E R > 
EDV+INTERNETSERVICE GMBH

POST: August Bebel Str. 69
      04275 Leipzig

FON:  +49 341 30 34 833
FAX:  +49 341 30 34 840
WEB:  www.webmacher.de


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: xsl script to generate graphical representation of build.xml

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
Eager to see what this thing could do with my build files, I *gasp* read the
docs and found exactly what I needed.  Attached is a slightly modified
version of Stefan's original XSL file - all I did was enclose all the node
names with double quotes.

Let me know if you want this contributed to Ant's CVS.  This would even make
a handy custom Ant task, to wrap calling dot.exe - although I'll get by with
<xslt> and <exec> for now.

Very nice, Stefan.

Thanks,
    Erik

----- Original Message -----
From: "Erik Hatcher" <ja...@ehatchersolutions.com>
To: "Ant Users List" <an...@jakarta.apache.org>
Sent: Wednesday, June 05, 2002 7:58 PM
Subject: Re: xsl script to generate graphical representation of build.xml


> This looks pretty slick.  I tried it out and got this while running 'dot'
>
> graph parser: syntax error near line 18
> context:    >>>  do- <<< common [label="do-common\n"];
>
> Looks like it doesn't like dashes in target names.  Is there a way to have
> them escaped in the .dot files?  Would you modify it so that it could work
> in such cases?  It still generated a .png, but it looked incomplete.
>
> Many thanks for this contribution.  Would you mind this being committed to
> Ant's CVS for inclusion into Ant 1.6?  If so, let me know.
>
>     Erik
>
> ----- Original Message -----
> From: "Stefan Kost" <s....@webmacher.de>
> To: "Ant Users List" <an...@jakarta.apache.org>
> Cc: <an...@jakarta.apache.org>
> Sent: Wednesday, June 05, 2002 4:50 AM
> Subject: xsl script to generate graphical representation of build.xml
>
>
> > hi,
> >
> > attached you find a xsl script, which generates a .dot out of a
> > build.xml file. The dot file can be rendered using the dot command (from
> > the graphviz package, see http://www.graphviz.org/) to lots of formats
> > like ps or png.
> > Minimal instructions are in the xsl file.
> >
> > Stefan
> > --
> >
> >  < W E B M A C H E R >
> > EDV+INTERNETSERVICE GMBH
> >
> > POST: August Bebel Str. 69
> >       04275 Leipzig
> >
> > FON:  +49 341 30 34 833
> > FAX:  +49 341 30 34 840
> > WEB:  www.webmacher.de
> >
>
>
> --------------------------------------------------------------------------
--
> ----
>
>
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>

Re: xsl script to generate graphical representation of build.xml

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
This looks pretty slick.  I tried it out and got this while running 'dot'

graph parser: syntax error near line 18
context:    >>>  do- <<< common [label="do-common\n"];

Looks like it doesn't like dashes in target names.  Is there a way to have
them escaped in the .dot files?  Would you modify it so that it could work
in such cases?  It still generated a .png, but it looked incomplete.

Many thanks for this contribution.  Would you mind this being committed to
Ant's CVS for inclusion into Ant 1.6?  If so, let me know.

    Erik

----- Original Message -----
From: "Stefan Kost" <s....@webmacher.de>
To: "Ant Users List" <an...@jakarta.apache.org>
Cc: <an...@jakarta.apache.org>
Sent: Wednesday, June 05, 2002 4:50 AM
Subject: xsl script to generate graphical representation of build.xml


> hi,
>
> attached you find a xsl script, which generates a .dot out of a
> build.xml file. The dot file can be rendered using the dot command (from
> the graphviz package, see http://www.graphviz.org/) to lots of formats
> like ps or png.
> Minimal instructions are in the xsl file.
>
> Stefan
> --
>
>  < W E B M A C H E R >
> EDV+INTERNETSERVICE GMBH
>
> POST: August Bebel Str. 69
>       04275 Leipzig
>
> FON:  +49 341 30 34 833
> FAX:  +49 341 30 34 840
> WEB:  www.webmacher.de
>


----------------------------------------------------------------------------
----


> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: xsl script to generate graphical representation of build.xml

Posted by Stefan Kost <s....@webmacher.de>.
Hi again,

this version incorporates the changes from Erik and Nascif.
It further highlights callable targets (bold borders).
I am not sure if this enhances the look. The hightlighting could be done
via color as well (e.g. blue link links in a html page).
What do you think? I can even move those things to top of the file as
xsl:variable, so it could finally move outside to a separate xsl file
which one could easilly adapt.

> hi,
> 
> attached you find a xsl script, which generates a .dot out of a
> build.xml file. The dot file can be rendered using the dot command (from
> the graphviz package, see http://www.graphviz.org/) to lots of formats
> like ps or png.
> Minimal instructions are in the xsl file.


-- 

 < W E B M A C H E R > 
EDV+INTERNETSERVICE GMBH

POST: August Bebel Str. 69
      04275 Leipzig

FON:  +49 341 30 34 833
FAX:  +49 341 30 34 840
WEB:  www.webmacher.de