sascha@351: <?xml version="1.0" encoding="UTF-8"?> sascha@351: sascha@351: <!-- sascha@351: Copyright (c) 2010 by Intevation GmbH sascha@351: sascha@351: This program is free software under the LGPL (>=v2.1) sascha@351: Read the file LGPL.txt coming with the software for details sascha@351: or visit http://www.gnu.org/licenses/ if it does not exist. sascha@351: sascha@351: Author: Sascha L. Teichmann (sascha.teichmann@intevation.de) sascha@351: --> sascha@351: sascha@351: <xsl:stylesheet sascha@351: xmlns:xsl="http://www.w3.org/1999/XSL/Transform" sascha@351: xmlns:xlink="http://www.w3.org/1999/xlink" sascha@351: version="1.0"> sascha@351: sascha@351: <xsl:output method="text" encoding="UTF-8"/> sascha@351: sascha@351: <xsl:param name="base-dir">.</xsl:param> sascha@351: sascha@351: <xsl:template match="/"> sascha@351: <xsl:text>digraph transition_model {
</xsl:text> sascha@351: <xsl:apply-templates /> sascha@351: <xsl:text>}
</xsl:text> sascha@351: </xsl:template> sascha@351: sascha@351: <xsl:template match="artifact"> sascha@351: <xsl:choose> sascha@351: <xsl:when test="@xlink:href != ''"> sascha@351: <!-- handle external artifacts --> sascha@351: <xsl:variable name="path"> sascha@351: <xsl:call-template name="string-replace-all"> sascha@351: <xsl:with-param name="text" select="@xlink:href" /> sascha@351: <xsl:with-param name="replace">${artifacts.config.dir}</xsl:with-param> sascha@351: <xsl:with-param name="by" select="$base-dir" /> sascha@351: </xsl:call-template> sascha@351: </xsl:variable> sascha@351: <xsl:for-each select="document($path)"> sascha@351: <xsl:apply-templates select="/artifact"/> sascha@351: </xsl:for-each> sascha@351: </xsl:when> sascha@351: <xsl:otherwise> sascha@351: <!-- handle internal artifacts --> sascha@351: <xsl:text>subgraph </xsl:text><xsl:value-of select="@name"/> sascha@351: <xsl:text> {
</xsl:text> sascha@351: <xsl:text> label = "Artefakt: </xsl:text> sascha@351: <xsl:value-of select="@name"/> sascha@351: <xsl:text>";
</xsl:text> sascha@351: <xsl:apply-templates mode="inside-artifact" select="./states/state"/> sascha@351: <xsl:apply-templates mode="inside-artifact" select="./states/transition"/> sascha@351: <xsl:text>}
</xsl:text> sascha@351: </xsl:otherwise> sascha@351: </xsl:choose> sascha@351: </xsl:template> sascha@351: sascha@351: <xsl:template match="state" mode="inside-artifact"> sascha@351: <xsl:text> "</xsl:text> sascha@351: <xsl:value-of select="@id"/> sascha@351: <xsl:text disable-output-escaping="yes" sascha@351: >" [ shape = "record" label=<<table border="0" cellborder="0" cellpadding="3"> sascha@351: <tr><td align="center" colspan="2" bgcolor="black"><font color="white"></xsl:text> sascha@351: <xsl:value-of select="@id"/> sascha@351: <xsl:text disable-output-escaping="yes" sascha@351: ></font></td></tr></xsl:text> sascha@351: <xsl:apply-templates mode="inside-artifact" /> sascha@351: <xsl:text disable-output-escaping="yes" sascha@351: ></table>>]</xsl:text> sascha@351: <xsl:text>;
</xsl:text> sascha@351: </xsl:template> sascha@351: sascha@351: <xsl:template match="data" mode="inside-artifact"> sascha@351: <xsl:text disable-output-escaping="yes" sascha@351: ><tr><td align="right"></xsl:text> sascha@351: <xsl:value-of select="@name"/> sascha@351: <xsl:text disable-output-escaping="yes" sascha@351: ></td><td align="left"></xsl:text> sascha@351: <xsl:value-of select="@type"/> sascha@351: <xsl:text disable-output-escaping="yes" sascha@351: ></td></tr></xsl:text> sascha@351: </xsl:template> sascha@351: sascha@351: <xsl:template match="transition" mode="inside-artifact"> sascha@351: <xsl:text> "</xsl:text> sascha@351: <xsl:value-of select="from/@state"/> sascha@351: <xsl:text disable-output-escaping="yes">" -> "</xsl:text> sascha@351: <xsl:value-of select="to/@state"/> sascha@384: <xsl:text>"</xsl:text> sascha@351: <xsl:apply-templates mode="inside-artifact"/> sascha@384: <xsl:text>;
</xsl:text> sascha@351: </xsl:template> sascha@351: sascha@351: <xsl:template match="condition" mode="inside-artifact"> sascha@351: <xsl:text> [ label="</xsl:text> sascha@351: <xsl:value-of select="@inputvalue"/> sascha@351: <xsl:text> </xsl:text> sascha@351: <xsl:value-of select="@operator"/> sascha@351: <xsl:text> </xsl:text> sascha@351: <xsl:value-of select="@value"/> sascha@351: <xsl:text>" ]</xsl:text> sascha@351: </xsl:template> sascha@351: sascha@351: <xsl:template match="text()" mode="inside-artifact"/> sascha@351: <xsl:template match="text()"/> sascha@351: sascha@351: <xsl:template name="string-replace-all"> sascha@351: <xsl:param name="text" /> sascha@351: <xsl:param name="replace" /> sascha@351: <xsl:param name="by" /> sascha@351: <xsl:choose> sascha@351: <xsl:when test="contains($text, $replace)"> sascha@351: <xsl:value-of select="substring-before($text,$replace)" /> sascha@351: <xsl:value-of select="$by" /> sascha@351: <xsl:call-template name="string-replace-all"> sascha@351: <xsl:with-param name="text" sascha@351: select="substring-after($text,$replace)" /> sascha@351: <xsl:with-param name="replace" select="$replace" /> sascha@351: <xsl:with-param name="by" select="$by" /> sascha@351: </xsl:call-template> sascha@351: </xsl:when> sascha@351: <xsl:otherwise> sascha@351: <xsl:value-of select="$text" /> sascha@351: </xsl:otherwise> sascha@351: </xsl:choose> sascha@351: </xsl:template> sascha@351: sascha@351: </xsl:stylesheet> sascha@351: