savaged.info

2006-10-25

gantt project report gan2html.xsl

Filed under: General,software,technology,workfriendly — savaged @ 14:48

I’ve been using “Gantt Project” www.ganttproject.org and find it quite good. However, presenting the end result is not so great. Therefore I’ve started to create a xslt transform on the xml “gan” file.

I’m including it here so that others can use and improve it:

 <?xml version=”1.0″ encoding=”iso-8859-2″?>

<xsl:stylesheet xmlns:xsl=”http://www.w3.org/1999/XSL/Transform version=”1.0“>

<xsl:output media-type=”html encoding=”iso-8859-2“/>

<xsl:template match=”/“>

<html>

<head>

<title>

<xsl:value-of select=”project/description“/>

</title>

<style type=”text/css“>

/* <![CDATA[ */

@import "/branding/css/tigris.css";

@import "/branding/css/inst.css";

/* ]]> */

</style>

</head>

<body>

<h1>Milestone Project Plan</h1>

<h2>

<xsl:value-of select=”project/description“/>

</h2>

<table border=”1“>

<colgroup>

<col width=”5%“/>

<col/>

<col width=”10%“/>

<col width=”10%“/>

<col width=”10%“/>

</colgroup>

<tr>

<th>Priority</th>

<th>Task</th>

<th>Start</th>

<th>Duration</th>

<th>% Complete</th>

</tr>

<xsl:for-each select=”project/tasks/task“>

<tr>

<td>

<xsl:value-of select=”@priority“/>

</td>

<td>

<xsl:value-of select=”@name“/>

</td>

<td>

<xsl:value-of select=”@start“/>

</td>

<td>

<xsl:value-of select=”@duration“/>

</td>

<td>

<xsl:value-of select=”@complete“/>

</td>

</tr>

</xsl:for-each>

</table>

</body>

</html>

</xsl:template>

</xsl:stylesheet>

Advertisement

9 Comments

  1. Hi,

    this is great, just what i want to find, now a minor question, how do i parse the project file with this xsl file on a webserver like apache or iis?

    im probably just being thick, but im failing to find this simple information anywhere out on the web

    Comment by Alan — 2006-11-15 @ 16:06

  2. There are various ways but i just add something like this: to the top of the gantt file:
    <?xml-stylesheet
    type=”text/xsl”
    href=”gan2html.xsl”?>
    NOTE: There is a little gotcha where Proj Gantt removes it each time it saves so you have to go back and put it in again. I’m sure there’s a better way but I’m lazy :)

    Comment by savaged — 2006-11-15 @ 16:33

  3. I’ve made a few tweaks to my original:

    <?xml
    version=”1.0″ encoding=”iso-8859-2″?>
    <xsl:stylesheet
    xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”
    version=”1.0″>
    <xsl:output
    media-type=”html”
    encoding=”iso-8859-2″/>
    <xsl:template
    match=”/project”>
    <html>
    <head>
    <title>
    <xsl:value-of
    select=”description”/>
    </title>
    <style
    type=”text/css”>
    /*
    <![CDATA[
    */
    @import
    "/branding/css/tigris.css";
    @import
    "/branding/css/inst.css";
    /*
    ]]> */
    </style>
    </head>
    <body>
    <h1>
    <xsl:value-of
    select=”@name”/>
    </h1>
    <h2>Project
    Description</h2>
    <p>
    <xsl:value-of
    select=”description”/>
    </p>
    <p>
    <a>
    <xsl:attribute
    name=”href”><xsl:value-of
    select=”@webLink”/></xsl:attribute>
    <xsl:value-of
    select=”@webLink”/>
    </a>
    </p>
    <h2>Task
    List</h2>
    <table
    border=”1″>
    <colgroup>
    <col
    width=”5%”/>
    <col/>
    <col
    width=”10%”/>
    <col
    width=”10%”/>
    <col
    width=”10%”/>
    </colgroup>
    <tr>
    <th>priority</th>
    <th>task</th>
    <th>start</th>
    <th>days
    elapsed</th>
    <th>completion</th>
    </tr>
    <xsl:for-each
    select=”tasks/task”>
    <tr>
    <td>
    <xsl:choose>
    <xsl:when
    test=”@priority=’0′”>
    low
    </xsl:when>
    <xsl:when
    test=”@priority=’1′”>
    norm
    </xsl:when>
    <xsl:when
    test=”@priority=’2′”>
    high
    </xsl:when>
    </xsl:choose>
    </td>
    <td>
    <xsl:value-of
    select=”@name”/>
    </td>
    <td>
    <xsl:value-of
    select=”@start”/>
    </td>
    <td>
    <xsl:value-of
    select=”@duration”/>
    </td>
    <td>
    <xsl:value-of
    select=”@complete”/>
    </td>
    </tr>
    </xsl:for-each>
    </table>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>

    Comment by savaged — 2006-11-15 @ 16:40

  4. this blog keep garlbling this xsl, i found some asp code that would automatically parse a specified xsl against the gan file. I have made a little customisation to this so that the task notes are included.
    If you want a copy, please email me.

    any idea how to show what resource the task is allocated to, im also have a little table at the bottom that shows what role each resource does.

    Comment by Alan — 2006-11-16 @ 9:23

  5. found out how to list names of people allocated the task. just add the below as an additional column

    Comment by Alan — 2006-11-28 @ 12:57

  6. ok, as the code doesn’t appear have a look at http:// maiaandalan.fireflyinternet.co.uk /ganttproject.html

    Comment by Alan — 2006-11-28 @ 13:10

  7. adding my link

    Comment by Alan — 2006-11-28 @ 14:01

  8. Looks good, thanks for sharing your work :)

    <?xml
    version="1.0" encoding="iso-8859-2"?>
    <xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform&quot;
    version="1.0">
    <xsl:output
    media-type="html"
    encoding="iso-8859-2"/>
    <xsl:template
    match="/project">
    <html>

    <head>

    <title>

    <xsl:value-of
    select="description"/>

    </title>

    <style
    type="text/css">
    /*
    <![CDATA[
    */
    @import
    "/branding/css/tigris.css";
    @import
    "/branding/css/inst.css";
    /*
    ]]> */

    </style>

    </head>

    <body>

    <h1>

    <xsl:value-of
    select="@name"/>

    </h1>

    <h2>Project
    Description</h2>

    <p>

    <xsl:value-of
    select="description"/>

    </p>

    <p>

    <a>

    <xsl:attribute
    name="href"><xsl:value-of
    select="@webLink"/></xsl:attribute>

    <xsl:value-of
    select="@webLink"/>

    </a>

    </p>

    <h2>Task
    List</h2>

    <table
    border="1">

    <tr>

    <th>priority</th>

    <th>task</th>

    <th>start</th>

    <th>days</th>

    <th>completion</th>

    <th>resource</th>

    <th>notes</th>

    </tr>

    <xsl:for-each
    select="tasks/task">

    <tr>

    <xsl:call-template
    name="transform-task"/>

    <xsl:if
    test="task">

    <tr>

    <td
    colspan="7"
    align="right"
    valign="top">

    <table
    border="1"
    width="95%">

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

    <tr>

    <xsl:call-template
    name="transform-task"/>

    </tr>

    </xsl:for-each>

    </table>

    </td>

    </tr>

    </xsl:if>

    </tr>

    </xsl:for-each>

    </table>

    <h2>Resources</h2>

    <table
    border="1">

    <colgroup>

    <col/>

    <col/>

    <col/>

    </colgroup>

    <tr>

    <th>Resource</th>

    <th>Email</th>

    <th>Phone</th>

    </tr>

    <xsl:for-each
    select="resources/resource">

    <tr>

    <td>

    <xsl:value-of
    select="@name"/>

    </td>

    <td>

    <xsl:value-of
    select="@contacts"/>

    </td>

    <td>

    <xsl:value-of
    select="@phone"/>

    </td>

    </tr>

    </xsl:for-each>

    </table>

    </body>
    </html>

    </xsl:template>
    <xsl:template
    name="transform-task">
    <td>

    <xsl:choose>

    <xsl:when
    test="@priority=’0′">

    low

    </xsl:when>

    <xsl:when
    test="@priority=’1′">
    norm

    </xsl:when>

    <xsl:when
    test="@priority=’2′">

    high

    </xsl:when>

    </xsl:choose>
    </td>
    <td>

    <xsl:value-of
    select="@name"/>
    </td>
    <td>

    <xsl:value-of
    select="@start"/>
    </td>
    <td>

    <xsl:value-of
    select="@duration"/>
    </td>
    <td>

    <xsl:value-of
    select="@complete"/>

    <xsl:text>%</xsl:text>
    </td>
    <td>

    <xsl:for-each
    select="../../allocations/allocation[@task-id
    = current()/@id]">

    <xsl:for-each
    select="../../resources/resource[@id
    = current()/@resource-id]">

    <xsl:value-of
    select="@name"/>

    <br/>

    </xsl:for-each>

    </xsl:for-each>
    </td>
    <td>

    <xsl:value-of
    select="notes"/>
    <br/>
    </td>

    </xsl:template>
    </xsl:stylesheet>

    Comment by savaged — 2006-11-28 @ 14:06

  9. Alan’s site has all of his GanttProject transform work nicely laid out for reference – http://maiaandalan.fireflyinternet.co.uk/ganttproject.shtml

    Comment by savaged — 2006-12-22 @ 11:11


RSS feed for comments on this post.

Theme: Rubric. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 57 other followers