Command executed to generate debian application dependency graph using dot languge:
#!/bin/bash xsltproc System.xsl System.xml > System.dot dot -Tpng -o System.png System.dot
System.xml
<?xml version="1.0" encoding="UTF-8"?> <!--System.xml Exception: Node can't contain &. --> <System xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\Xuan_Temp\del\System.xsd"> <Distribution Version="4.0r1" Name="Debian Etch"> <Application Id="Debian" Version="??" Name="Debian Etch" PackageName="Debian"> <Description>GNU/Linux OS</Description> </Application> <Application Id="x-window-system" Version="??" Name="x-window-system" PackageName="x-window-system"> <Description>x-window-system</Description> </Application> <Application Id="wmaker" Version="0.90" Name="Windowmaker" PackageName="wmaker"> <Description>A window manager</Description> </Application> <Application Id="leafpad" Version="??" Name="leafpad" PackageName="leafpad"> <Description>A simple graphic text editor</Description> </Application> <Application Id="iceweasel" Version="??" Name="Firefox" PackageName="iceweasel"> <Description>An internet browser</Description> </Application> <Application Id="xtightvncviewer" Version="??" Name="xtightvncviewer" PackageName="xtightvncviewer"> <Description>Remote control viewer</Description> </Application> <Application Id="k3b" Version="??" Name="k3b" PackageName="k3b"> <Description>Burning CD/DVD</Description> </Application> <Application Id="dia" Version="??" Name="dia" PackageName="dia"> <Description>AVisio like application</Description> </Application> <Application Id="mplayer" Version="??" Name="mplayer" PackageName="mplayer"> <Description>Media player</Description> <!-- head -n22 /usr/share/mplayer/scripts/binary_codecs.sh mkdir /usr/lib/codecs cp *codecs /usr/lib/codecs --> </Application> <Application Id="gkrellm" Version="??" Name="gkrellm" PackageName="gkrellm"> <Description>A single process stack of system monitors</Description> </Application> <Application Id="gqivew" Version="??" Name="gqivew" PackageName="gqivew"> <Description>Picture viewer</Description> </Application> <Application Id="alsa" Version="??" Name="alsa" PackageName="alsa"> <Description>Sound driver configurator</Description> </Application> <Application Id="hwinfo" Version="??" Name="hwinfo" PackageName="hwinfo"> <Description>Hardware Info</Description> </Application> <Application Id="graphviz" Version="??" Name="graphviz" PackageName="graphviz"> <Description>??</Description> </Application> <Application Id="gawk" Version="??" Name="gawk" PackageName="gawk"> <Description>??</Description> </Application> <Application Id="sed" Version="??" Name="sed" PackageName="sed"> <Description>??</Description> </Application> <Application Id="ntfs-3g" Version="??" Name="ntfs-3g" PackageName="ntfs-3g"> <Description>??</Description> </Application> <Application Id="xsltproc" Version="??" Name="xsltproc" PackageName="xsltproc"> <Description>??</Description> </Application> <Application Id="docbook" Version="??" Name="docbook" PackageName="docbook"> <Description>??</Description> </Application> <Application Id="rar" Version="??" Name="rar" PackageName="rar"> <Description>??</Description> </Application> <Application Id="unzip" Version="??" Name="unzip" PackageName="unzip"> <Description>??</Description> </Application> <Application Id="lxsplit" Version="??" Name="lxsplit" PackageName="lxsplit"> <Description>??</Description> </Application> <Application Id="acroread" Version="??" Name="Adobe Acrobat Reader" PackageName="acroread"> <Description>PDF file viewer</Description> </Application> <Dependency> <Package Id="Debian"> <Package Id="x-window-system"> <Package Id="wmaker"> <Package Id="leafpad"/> <Package Id="iceweasel"/> <Package Id="xtightvncviewer"/> <Package Id="k3b"/> <Package Id="dia"/> <Package Id="mplayer"/> <Package Id="gkrellm"/> <Package Id="gqivew"/> <Package Id="acroread"/> </Package> </Package> <Package Id="alsa"/> <Package Id="hwinfo"/> <Package Id="graphviz"/> <Package Id="gawk"/> <Package Id="sed"/> <Package Id="ntfs-3g"/> <Package Id="xsltproc"> <Package Id="docbook"> </Package> </Package> <Package Id="rar"/> <Package Id="unzip"/> <Package Id="lxsplit"/> </Package> </Dependency> </Distribution> </System>
System.xsl
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"> <xsl:output encoding="UTF-8" method="text"/> <xsl:template match="/"> <xsl:text>digraph System {

</xsl:text> <xsl:for-each select="System/Distribution"> <!-- Subgraph name --> <xsl:variable name="vSubgraphName"> <xsl:call-template name="ReplaceCharsInString"> <xsl:with-param name="stringIn" select="@Name"/> <xsl:with-param name="charsIn" select="'&'"/> <xsl:with-param name="charsOut" select="''"/> </xsl:call-template> </xsl:variable> <xsl:text>subgraph "cluster</xsl:text> <xsl:value-of select="$vSubgraphName"/><xsl:text>" {
</xsl:text> <xsl:text>node [style=filled];
</xsl:text> <!-- Subgraph info --> <xsl:text>label = "Dependency graph of </xsl:text> <xsl:value-of select="@Name"/><xsl:text> [</xsl:text> <xsl:value-of select="@Version"/><xsl:text>]";
</xsl:text> <!-- <xsl:value-of select="Description"/><xsl:text>
</xsl:text><xsl:text>
</xsl:text> --> <xsl:text>color=blue;

</xsl:text> <!-- Application info --> <xsl:for-each select="Application"> <!-- Escape spaces in label--> <xsl:variable name="vName"> <xsl:call-template name="ReplaceCharsInString"> <xsl:with-param name="stringIn" select="@Name"/> <xsl:with-param name="charsIn" select="' '"/> <xsl:with-param name="charsOut" select="'\ '"/> </xsl:call-template> </xsl:variable> <xsl:variable name="vVersion"> <xsl:call-template name="ReplaceCharsInString"> <xsl:with-param name="stringIn" select="@Version"/> <xsl:with-param name="charsIn" select="' '"/> <xsl:with-param name="charsOut" select="'\ '"/> </xsl:call-template> </xsl:variable> <xsl:variable name="vPackageName"> <xsl:call-template name="ReplaceCharsInString"> <xsl:with-param name="stringIn" select="@PackageName"/> <xsl:with-param name="charsIn" select="' '"/> <xsl:with-param name="charsOut" select="'\ '"/> </xsl:call-template> </xsl:variable> <xsl:variable name="vDescription"> <xsl:call-template name="ReplaceCharsInString"> <xsl:with-param name="stringIn" select="Description"/> <xsl:with-param name="charsIn" select="' '"/> <xsl:with-param name="charsOut" select="'\ '"/> </xsl:call-template> </xsl:variable> <!-- Escape & in node name--> <xsl:variable name="vId"> <xsl:call-template name="ReplaceCharsInString"> <xsl:with-param name="stringIn" select="@Id"/> <xsl:with-param name="charsIn" select="'&'"/> <xsl:with-param name="charsOut" select="''"/> </xsl:call-template> </xsl:variable> <!-- Write application info --> <xsl:text>"</xsl:text> <xsl:value-of select="$vId"/><xsl:text>" [shape=Mrecord, style=filled, color=green, label = "{</xsl:text> <xsl:value-of select="$vName"/><xsl:text> [</xsl:text> <xsl:value-of select="$vVersion"/><xsl:text>] | </xsl:text> <xsl:value-of select="$vPackageName"/><xsl:text> | </xsl:text> <xsl:value-of select="$vDescription"/><xsl:text>}"];
</xsl:text> </xsl:for-each> <xsl:text>
</xsl:text> <!-- Dependency --> <xsl:for-each select="Dependency"> <xsl:for-each select="Package"><!-- Skip the first node --> <xsl:for-each select="descendant::*"> <!-- Escape & in node name--> <xsl:variable name="vPrevId"> <xsl:call-template name="ReplaceCharsInString"> <xsl:with-param name="stringIn" select="../@Id"/> <xsl:with-param name="charsIn" select="'&'"/> <xsl:with-param name="charsOut" select="''"/> </xsl:call-template> </xsl:variable> <xsl:variable name="vCurrId"> <xsl:call-template name="ReplaceCharsInString"> <xsl:with-param name="stringIn" select="@Id"/> <xsl:with-param name="charsIn" select="'&'"/> <xsl:with-param name="charsOut" select="''"/> </xsl:call-template> </xsl:variable> <xsl:text>"</xsl:text><xsl:value-of select="$vPrevId"/><xsl:text>" -> "</xsl:text><xsl:value-of select="$vCurrId"/><xsl:text>";
</xsl:text> </xsl:for-each> </xsl:for-each> </xsl:for-each> <xsl:text>}
</xsl:text> </xsl:for-each> <xsl:text>}</xsl:text> </xsl:template> <!-- Template to Replace char in String --> <xsl:template name="ReplaceCharsInString"> <xsl:param name="stringIn"/> <xsl:param name="charsIn"/> <xsl:param name="charsOut"/> <xsl:choose> <xsl:when test="contains($stringIn,$charsIn)"> <xsl:value-of select="concat(substring-before($stringIn,$charsIn),$charsOut)"/> <xsl:call-template name="ReplaceCharsInString"> <xsl:with-param name="stringIn" select="substring-after($stringIn,$charsIn)"/> <xsl:with-param name="charsIn" select="$charsIn"/> <xsl:with-param name="charsOut" select="$charsOut"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$stringIn"/> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet>
Dot Output
digraph System { subgraph "clusterDebian Etch" { node [style=filled]; label = "Dependency graph of Debian Etch [4.0r1]"; color=blue; "Debian" [shape=Mrecord, style=filled, color=green, label = "{Debian\ Etch [??] | Debian | GNU/Linux\ OS}"]; "x-window-system" [shape=Mrecord, style=filled, color=green, label = "{x-window-system [??] | x-window-system | x-window-system}"]; "wmaker" [shape=Mrecord, style=filled, color=green, label = "{Windowmaker [0.90] | wmaker | A\ window\ manager}"]; "leafpad" [shape=Mrecord, style=filled, color=green, label = "{leafpad [??] | leafpad | A\ simple\ graphic\ text\ editor}"]; "iceweasel" [shape=Mrecord, style=filled, color=green, label = "{Firefox [??] | iceweasel | An\ internet\ browser}"]; "xtightvncviewer" [shape=Mrecord, style=filled, color=green, label = "{xtightvncviewer [??] | xtightvncviewer | Remote\ control\ viewer}"]; "k3b" [shape=Mrecord, style=filled, color=green, label = "{k3b [??] | k3b | Burning\ CD/DVD}"]; "dia" [shape=Mrecord, style=filled, color=green, label = "{dia [??] | dia | AVisio\ like\ application}"]; "mplayer" [shape=Mrecord, style=filled, color=green, label = "{mplayer [??] | mplayer | Media\ player}"]; "gkrellm" [shape=Mrecord, style=filled, color=green, label = "{gkrellm [??] | gkrellm | A\ single\ process\ stack\ of\ system\ monitors}"]; "gqivew" [shape=Mrecord, style=filled, color=green, label = "{gqivew [??] | gqivew | Picture\ viewer}"]; "alsa" [shape=Mrecord, style=filled, color=green, label = "{alsa [??] | alsa | Sound\ driver\ configurator}"]; "hwinfo" [shape=Mrecord, style=filled, color=green, label = "{hwinfo [??] | hwinfo | Hardware\ Info}"]; "graphviz" [shape=Mrecord, style=filled, color=green, label = "{graphviz [??] | graphviz | ??}"]; "gawk" [shape=Mrecord, style=filled, color=green, label = "{gawk [??] | gawk | ??}"]; "sed" [shape=Mrecord, style=filled, color=green, label = "{sed [??] | sed | ??}"]; "ntfs-3g" [shape=Mrecord, style=filled, color=green, label = "{ntfs-3g [??] | ntfs-3g | ??}"]; "xsltproc" [shape=Mrecord, style=filled, color=green, label = "{xsltproc [??] | xsltproc | ??}"]; "docbook" [shape=Mrecord, style=filled, color=green, label = "{docbook [??] | docbook | ??}"]; "rar" [shape=Mrecord, style=filled, color=green, label = "{rar [??] | rar | ??}"]; "unzip" [shape=Mrecord, style=filled, color=green, label = "{unzip [??] | unzip | ??}"]; "lxsplit" [shape=Mrecord, style=filled, color=green, label = "{lxsplit [??] | lxsplit | ??}"]; "acroread" [shape=Mrecord, style=filled, color=green, label = "{Adobe\ Acrobat\ Reader [??] | acroread | PDF\ file\ viewer}"]; "Debian" -> "x-window-system"; "x-window-system" -> "wmaker"; "wmaker" -> "leafpad"; "wmaker" -> "iceweasel"; "wmaker" -> "xtightvncviewer"; "wmaker" -> "k3b"; "wmaker" -> "dia"; "wmaker" -> "mplayer"; "wmaker" -> "gkrellm"; "wmaker" -> "gqivew"; "wmaker" -> "acroread"; "Debian" -> "alsa"; "Debian" -> "hwinfo"; "Debian" -> "graphviz"; "Debian" -> "gawk"; "Debian" -> "sed"; "Debian" -> "ntfs-3g"; "Debian" -> "xsltproc"; "xsltproc" -> "docbook"; "Debian" -> "rar"; "Debian" -> "unzip"; "Debian" -> "lxsplit"; } }