grim/gir-tools

Initial revision

2016-02-24, Gary Kramlich
83d89bba0694
Parents
Children 7d979d896f64
Initial revision
  • +59 -0
    gir2dot.xsl
  • --- /dev/null Thu Jan 01 00:00:00 1970 +0000
    +++ b/gir2dot.xsl Wed Feb 24 18:22:02 2016 -0600
    @@ -0,0 +1,59 @@
    +<?xml version="1.0" encoding="utf-8"?>
    +<xsl:stylesheet
    + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    + xmlns:gir="http://www.gtk.org/introspection/core/1.0"
    + version="1.0"
    +>
    + <xsl:output method="text"/>
    + <xsl:strip-space elements="*"/>
    +
    + <xsl:variable name="newline" select="'&#10;'"/>
    + <xsl:variable name="tab" select="'&#9;'"/>
    +
    + <xsl:variable name="newline-tab">
    + <xsl:value-of select="$newline"/>
    + <xsl:value-of select="$tab"/>
    + </xsl:variable>
    +
    + <xsl:template match="gir:method">
    + <xsl:value-of select="@name"/>
    + <xsl:text>\l</xsl:text>
    + </xsl:template>
    +
    + <xsl:template match="gir:class">
    + <xsl:value-of select="$tab"/>
    + <xsl:value-of select="@name"/>
    + <xsl:text>[shape="record" label="{</xsl:text>
    + <xsl:value-of select="@name"/>
    + <xsl:if test="@abstract = '1'">
    + <xsl:text>\n\&lt;\&lt;abstract \&gt;\&gt;</xsl:text>
    + </xsl:if>
    + <xsl:text>||</xsl:text>
    + <xsl:apply-templates select="gir:method"/>
    + <xsl:text>}"]</xsl:text>
    + <xsl:value-of select="$newline"/>
    + </xsl:template>
    +
    + <xsl:template match="gir:namespace">
    + <xsl:text>digraph {</xsl:text>
    + <xsl:value-of select="$newline-tab"/>
    + <xsl:text>graph[label="</xsl:text>
    + <xsl:value-of select="@name"/>
    + <xsl:text>"]</xsl:text>
    + <xsl:value-of select="$newline"/>
    +
    + <xsl:apply-templates select="gir:class"/>
    +
    + <xsl:value-of select="$newline"/>
    + <xsl:text>}</xsl:text>
    + <xsl:value-of select="$newline"/>
    + </xsl:template>
    +
    + <xsl:template match="gir:repository">
    + <xsl:apply-templates select="gir:namespace"/>
    + </xsl:template>
    +
    + <xsl:template match="/">
    + <xsl:apply-templates select="gir:repository"/>
    + </xsl:template>
    +</xsl:stylesheet>