-
Notifications
You must be signed in to change notification settings - Fork 0
/
dump.xsl
73 lines (66 loc) · 2.08 KB
/
dump.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?xml version='1.0'?>
<!-- translates sqlsmith graphml output into graphviz -->
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:g="http://graphml.graphdrawing.org/xmlns"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd"
version='1.0'>
<xsl:output method="text" />
<xsl:template match="/g:graphml/g:graph">
<xsl:text>digraph ast {</xsl:text>
<xsl:apply-templates select="@*|node()"/>
<xsl:text>}</xsl:text>
</xsl:template>
<xsl:template match="g:data">
<xsl:choose>
<xsl:when test="@key = 'label'">
<xsl:text>label=</xsl:text>
<xsl:value-of select="text()"/>
<xsl:text>,</xsl:text>
</xsl:when>
<xsl:when test="@key = 'retries'">
<xsl:choose>
<xsl:when test="text() > 1000">
<xsl:text>fillcolor=firebrick,style=filled</xsl:text>
</xsl:when>
<xsl:when test="text() > 500">
<xsl:text>fillcolor=red,style=filled</xsl:text>
</xsl:when>
<xsl:when test="text() > 100">
<xsl:text>fillcolor=salmon,style=filled</xsl:text>
</xsl:when>
<xsl:when test="text() > 50">
<xsl:text>fillcolor=wheat,style=filled</xsl:text>
</xsl:when>
<xsl:when test="text() > 10">
<xsl:text>fillcolor=springgreen,style=filled</xsl:text>
</xsl:when>
<xsl:when test="text() > 1">
<xsl:text>fillcolor=gainsboro,style=filled</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>fillcolor=white,style=filled</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text>,</xsl:text>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="g:node">
<xsl:value-of select="@id"/>
<xsl:text>[</xsl:text>
<xsl:apply-templates select="g:data"/>
<xsl:text>];
</xsl:text>
</xsl:template>
<xsl:template match="g:edge">
<xsl:value-of select="@source"/>
<xsl:text> -> </xsl:text>
<xsl:value-of select="@target"/>
<xsl:text>;
</xsl:text>
</xsl:template>
</xsl:transform>