Working with tools like Subversion and CVS in complex environments, it is easy to get a lot of parallel branches with separate developments and these become hard to maintain very quickly. In general, the best advice is to minimize the number of branches. But in some special cases, you just don't want to because you want to keep your options open. In such cases, you need to keep a proper administration of what happens where. A drawing usually helps, but making drawings takes a lot of time that can be spent on useful things....
<?xml version="1.0" encoding="UTF-8"?>
<roadmap main="trunk">
<branch id="f3" t="7" len="3">
<label>F 3</label>
<start level="f2"/>
<text t="1">tst</text>
<merge t="2" level="f2"/>
</branch>
<branch id="f2" t="5" len="8">
<label>F 2</label>
<start level="f1"/>
<text t="5">tst</text>
<merge t="6" level="integration"/>
</branch>
<branch id="f1" t="2" len="5">
<label>F 1</label>
<start level="trunk"/>
<text t="3">tst</text>
<merge t="4" level="integration"/>
</branch>
<branch id="integration" t="4" len="10">
<label>Integration</label>
<start level="trunk"/>
<text t="5">tst</text>
<text t="6">acc</text>
<merge t="8" level="trunk"/>
</branch>
<branch id="trunk" t="0" len="20">
<label>TRUNK</label>
</branch>
<branch id="release_march" t="14" len="5">
<label>RL 0803</label>
<start level="trunk"/>
<text t="3">tst</text>
<merge t="4" level="trunk"/>
</branch>
</roadmap>
...to a picture like this....

...only using code like this?
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:svg="http://www.w3.org/2000/svg" version="1.0">
<xsl:template match="//roadmap">
<xsl:variable name="main" select="@main"/>
<xsl:variable name="width" select="(branch[@id=$main]/@len + branch[@id=$main]/@t) * 3 + 2"/>
<xsl:variable name="height" select="count(branch) * 5 + 4"/>
<svg:svg width="{$width}cm" height="{$height}cm" viewBox="0.000 0.000 {$width} {$height}">
<xsl:apply-templates select="branch">
<xsl:with-param name="merge" select="'true'"/>
</xsl:apply-templates>
<xsl:apply-templates select="branch">
<xsl:with-param name="merge" select="'false'"/>
</xsl:apply-templates>
</svg:svg>
</xsl:template>
<xsl:template match="branch">
<xsl:param name="merge"/>
<xsl:variable name="start" select="@t * 3 + 1"/>
<xsl:variable name="end" select="$start + @len * 3"/>
<xsl:variable name="pos" select="count(./preceding-sibling::*) + 1"/>
<xsl:variable name="y" select="$pos * 5"/>
<svg:line x1="{$start}" y1="{$y}" x2="{$end}" y2="{$y}" stroke="#000000" stroke-width="1.000"/>
<xsl:choose>
<xsl:when test="$merge='true'">
<xsl:apply-templates select="merge">
<xsl:with-param name="pos" select="$pos"/>
<xsl:with-param name="y" select="$y"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="label">
<xsl:with-param name="start" select="$start"/>
<xsl:with-param name="pos" select="$pos"/>
<xsl:with-param name="y" select="$y"/>
</xsl:apply-templates>
<xsl:apply-templates select="start">
<xsl:with-param name="start" select="$start"/>
<xsl:with-param name="pos" select="$pos"/>
<xsl:with-param name="y" select="$y"/>
</xsl:apply-templates>
<xsl:apply-templates select="text">
<xsl:with-param name="pos" select="$pos"/>
<xsl:with-param name="y" select="$y"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="label">
<xsl:param name="start"/>
<xsl:param name="pos"/>
<xsl:param name="y"/>
<svg:text x="{$start + 1}" y="{$y + 0.5}" fill="#FFFFFF" text-anchor="start" font-size="0.80" font-family="sans" font-style="normal" font-weight="400">
<xsl:value-of select="."/>
</svg:text>
</xsl:template>
<xsl:template match="text">
<xsl:param name="pos"/>
<xsl:param name="y"/>
<xsl:variable name="start" select="(../@t + @t)* 3 + 1"/>
<svg:text x="{$start + 1}" y="{$y + 0.5}" fill="#FFFFFF" text-anchor="start" font-size="0.80" font-family="sans" font-style="normal" font-weight="400">
<xsl:value-of select="."/>
</svg:text>
</xsl:template>
<xsl:template match="start">
<xsl:param name="start"/>
<xsl:param name="pos"/>
<xsl:param name="y"/>
<xsl:variable name="level" select="@level"/>
<xsl:variable name="endpos" select="count(../../branch[@id=$level]/preceding-sibling::*) + 1"/>
<xsl:variable name="endy" select="$endpos * 5"/>
<svg:path stroke="#000000" fill="none" stroke-width="1.000" d="M {$start - 5},{$endy} C {$start - 2},{$endy} {$start - 3},{$y} {$start},{$y} "/>
</xsl:template>
<xsl:template match="merge">
<xsl:param name="pos"/>
<xsl:param name="y"/>
<xsl:variable name="start" select="(../@t + @t)* 3 + 1"/>
<xsl:variable name="level" select="@level"/>
<xsl:variable name="endpos" select="count(../../branch[@id=$level]/preceding-sibling::*) + 1"/>
<xsl:variable name="endy" select="$endpos * 5"/>
<svg:line x1="{$start}" y1="{$y}" x2="{$start}" y2="{$endy}" stroke="#000000" stroke-width="1.000"/>
<svg:line x1="{$start}" y1="{$y}" x2="{$start}" y2="{$endy}" stroke="#FFFFFF" stroke-width="1.000" stroke-dasharray="0.10,0.10"/>
</xsl:template>
</xsl:stylesheet>
Oh wait! You can! The only thing is that you need to convert the SVG file to a PNG file, but that can be done using several tools!
0 reacties:
Post a Comment