1 | <?xml version="1.0"?> |
---|
2 | <!-- Generic stylesheet for viewing XML --> |
---|
3 | <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
---|
4 | xmlns:my="myFunctions" |
---|
5 | xmlns:svg="http://www.w3.org/2000/svg" > |
---|
6 | |
---|
7 | <xsl:output method="text" encoding="utf-8" |
---|
8 | indent="yes" |
---|
9 | /> |
---|
10 | <!-- |
---|
11 | <purpose>transform a graph-xml (internal format) |
---|
12 | into a dot-format |
---|
13 | </purpose> |
---|
14 | <history> |
---|
15 | <change on="2012-05-17" type="created" by="vr">based on CMDI/scripts/cmd2dot.xsl</change> |
---|
16 | <change on="2012-12-05" type="created" by="vr">based on CMDI/scripts/cmd2graph-json-d3.xsl.xsl (split into cmd2graph and graph2json</change> |
---|
17 | <change on="2012-12-05" type="created" by="vr">based on CMDI/scripts/graph2json-d3.xsl</change> |
---|
18 | </history> |
---|
19 | <sample> |
---|
20 | --> |
---|
21 | |
---|
22 | <xsl:param name="title" select="'cmd-dep-graph'" /> |
---|
23 | |
---|
24 | <xsl:template match="/" > |
---|
25 | <xsl:apply-templates select="graph" mode="dot" ></xsl:apply-templates> |
---|
26 | </xsl:template> |
---|
27 | |
---|
28 | <xsl:template match="graph" mode="dot"> |
---|
29 | |
---|
30 | <xsl:text>digraph </xsl:text><xsl:value-of select="my:normalize($title)" /> |
---|
31 | <xsl:text>{ |
---|
32 | rankdir=LR; |
---|
33 | ranksep=1; |
---|
34 | label = "</xsl:text><xsl:value-of select="$title" /><xsl:text>"; |
---|
35 | size="12,12"; |
---|
36 | </xsl:text> |
---|
37 | <!-- |
---|
38 | /* |
---|
39 | graph [compound=true, mclimit=4, remincross=true |
---|
40 | ranksep=0.25, nodesep=0.18]; |
---|
41 | */ |
---|
42 | --> |
---|
43 | |
---|
44 | <xsl:apply-templates select="nodes" mode="dot"/> |
---|
45 | <xsl:text> |
---|
46 | </xsl:text> |
---|
47 | <xsl:apply-templates select="edges" mode="dot"/> |
---|
48 | <xsl:text> |
---|
49 | } /* end graph */</xsl:text> |
---|
50 | </xsl:template> |
---|
51 | |
---|
52 | <xsl:template match="nodes" mode="dot"> |
---|
53 | <xsl:text> /* nodes */ |
---|
54 | node [shape=none] |
---|
55 | </xsl:text> |
---|
56 | <xsl:apply-templates select="*" mode="dot"></xsl:apply-templates> |
---|
57 | <xsl:text> |
---|
58 | </xsl:text> |
---|
59 | </xsl:template> |
---|
60 | |
---|
61 | <xsl:template match="nodes/*" mode="dot"> |
---|
62 | <xsl:value-of select="@key" /> [label="<xsl:value-of select="@name" />", |
---|
63 | url="<xsl:value-of select="@id"/>"]; |
---|
64 | </xsl:template> |
---|
65 | |
---|
66 | <xsl:template match="edges" mode="dot"> |
---|
67 | <xsl:text> /* edges */</xsl:text> |
---|
68 | <xsl:apply-templates select="*" mode="dot"></xsl:apply-templates> |
---|
69 | <xsl:text> |
---|
70 | </xsl:text> |
---|
71 | </xsl:template> |
---|
72 | |
---|
73 | <xsl:template match="edges/*" mode="dot"> |
---|
74 | <xsl:value-of select="@from" /> -> <xsl:value-of select="@to" />; |
---|
75 | </xsl:template> |
---|
76 | |
---|
77 | <xsl:template match="text()"/> |
---|
78 | |
---|
79 | <!-- duplicated from cmd2graph ! --> |
---|
80 | <xsl:function name="my:normalize"> |
---|
81 | <xsl:param name="value" /> |
---|
82 | <xsl:value-of select="translate($value,'*/-.'',$@={}:[]()#>< ','XZ__')" /> |
---|
83 | </xsl:function> |
---|
84 | |
---|
85 | </xsl:stylesheet> |
---|