-
Notifications
You must be signed in to change notification settings - Fork 0
/
trafo.xsl
141 lines (141 loc) · 7.66 KB
/
trafo.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs">
<xsl:output method="xml" version="1.0" encoding="UTF-8" omit-xml-declaration="no" indent="yes" media-type="application/xml"/>
<xsl:template match="text()"/>
<xsl:key name="people-by-id" match="person" use="id"/>
<xsl:key name="children" match="family" use="child"/>
<xsl:key name="families-by-spouse" match="family" use="spouse"/>
<xsl:key name="families-by-id" match="family" use="id"/>
<xsl:template match="/xml[1]">
<xsl:element name="mxfile">
<xsl:attribute name="host">app.diagrams.net</xsl:attribute>
<xsl:attribute name="modified"><!-- xsl:value-of select="current-dateTime()"/--></xsl:attribute>
<xsl:attribute name="agent">5.0 (Windows)</xsl:attribute>
<xsl:attribute name="etag"><xsl:value-of select="generate-id()"/></xsl:attribute>
<xsl:attribute name="version">13.10.8</xsl:attribute>
<xsl:attribute name="type">device</xsl:attribute>
<xsl:apply-templates select="header[1]"/>
</xsl:element>
</xsl:template>
<xsl:template match="header">
<xsl:element name="diagram">
<xsl:attribute name="id"><xsl:value-of select="generate-id()"/></xsl:attribute>
<xsl:attribute name="name">Page-1</xsl:attribute>
<xsl:element name="mxGraphModel">
<xsl:attribute name="dx">0</xsl:attribute>
<xsl:attribute name="dy">0</xsl:attribute>
<xsl:attribute name="grid">1</xsl:attribute>
<xsl:attribute name="gridSize">10</xsl:attribute>
<xsl:attribute name="guides">1</xsl:attribute>
<xsl:attribute name="tooltips">1</xsl:attribute>
<xsl:attribute name="connect">1</xsl:attribute>
<xsl:attribute name="arrows">0</xsl:attribute>
<xsl:attribute name="fold">1</xsl:attribute>
<xsl:attribute name="page">1</xsl:attribute>
<xsl:attribute name="pageScale">1</xsl:attribute>
<xsl:attribute name="pageWidth">850</xsl:attribute>
<xsl:attribute name="pageHeight">1100</xsl:attribute>
<xsl:attribute name="math">0</xsl:attribute>
<xsl:attribute name="shadow">0</xsl:attribute>
<xsl:element name="root">
<xsl:element name="mxCell">
<xsl:attribute name="id">0</xsl:attribute>
</xsl:element>
<xsl:element name="mxCell">
<xsl:attribute name="id">1</xsl:attribute>
<xsl:attribute name="parent">0</xsl:attribute>
</xsl:element>
<xsl:apply-templates select="/xml[1]/family[child]"/>
<xsl:apply-templates select="/xml[1]/person[not(key('families-by-spouse',id)[1])]"/>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template match="child" mode="relate">
<xsl:variable name="child_id" select="normalize-space(text())"/>
<xsl:element name="mxCell">
<xsl:attribute name="id"><xsl:text>relate-</xsl:text><xsl:value-of select="$child_id"/><xsl:text>-</xsl:text><xsl:value-of select="generate-id()"/></xsl:attribute>
<xsl:attribute name="style">edgeStyle=orthogonalEdgeStyle;curved=1;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.46;entryY=0.013;entryDx=0;entryDy=0;entryPerimeter=0;endArrow=none;endFill=0;</xsl:attribute>
<xsl:attribute name="parent"><xsl:value-of select="../id/text()"/></xsl:attribute>
<xsl:attribute name="source"><xsl:value-of select="../id/text()"/></xsl:attribute>
<xsl:attribute name="target">
<xsl:choose>
<xsl:when test="key('families-by-spouse', $child_id)">
<xsl:value-of select="key('families-by-spouse', $child_id)[1]/id/text()"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$child_id"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="edge">1</xsl:attribute>
<xsl:element name="mxGeometry">
<xsl:attribute name="relative">1</xsl:attribute>
<xsl:attribute name="as">geometry</xsl:attribute>
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template match="spouse" mode="name">
<xsl:copy-of select="key('people-by-id', current()/text())[1]/name[1]/text()"/>
<xsl:choose>
<xsl:when test="position() = last()"/>
<xsl:otherwise><xsl:text> &amp; </xsl:text></xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="family">
<xsl:apply-templates select="child" mode="relate"/>
<xsl:element name="mxCell">
<xsl:attribute name="id"><xsl:value-of select='id/text()'/></xsl:attribute>
<xsl:attribute name="value"><xsl:apply-templates select="spouse" mode="name"/></xsl:attribute>
<xsl:choose>
<xsl:when test="endNode">
<xsl:attribute name="style">strokeWidth=2;html=1;shape=mxgraph.flowchart.terminator;whiteSpace=wrap;fillColor=#B5739D;strokeColor=#381410;fontColor=#ffffff;fontStyle=3;</xsl:attribute>
</xsl:when>
<xsl:when test="andThisNode">
<xsl:attribute name="style">rounded=1;whiteSpace=wrap;html=1;fillColor=#CDE2BE;strokeColor=#781410;fontColor=#000000;fontStyle=1;</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="style">rounded=1;whiteSpace=wrap;html=1;fillColor=#E6D0DE;strokeColor=#b85450;fontColor=#000000;</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:attribute name="parent">1</xsl:attribute>
<xsl:attribute name="vertex">1</xsl:attribute>
<xsl:element name="mxGeometry">
<xsl:attribute name="width">240</xsl:attribute>
<xsl:attribute name="height">60</xsl:attribute>
<xsl:attribute name="x"><xsl:value-of select="10 + (24 * position())"/></xsl:attribute>
<xsl:attribute name="y"><xsl:value-of select="16 + (56 * position())"/></xsl:attribute>
<xsl:attribute name="as">geometry</xsl:attribute>
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template match="person">
<xsl:element name="mxCell">
<xsl:attribute name="id"><xsl:value-of select="id/text()"/></xsl:attribute>
<xsl:attribute name="value"><xsl:value-of select="name[1]/text()"/></xsl:attribute>
<xsl:choose>
<xsl:when test="endNode">
<xsl:attribute name="style">strokeWidth=2;html=1;shape=mxgraph.flowchart.terminator;whiteSpace=wrap;fillColor=#FFFF99;strokeColor=#023406;fontColor=#000000;fontStyle=3;</xsl:attribute>
</xsl:when>
<xsl:when test="andThisNode">
<xsl:attribute name="style">ellipse;whiteSpace=wrap;html=1;fillColor=#99FFCC;strokeColor=#427326;fontColor=#000000;fontStyle=1;</xsl:attribute>
</xsl:when>
<xsl:when test="own-family and not(own-family/text() = '') and (key('families-by-id', current()/own-family/text())[*][child])">
<xsl:attribute name="style">rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontColor=#000000;</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="style">ellipse;whiteSpace=wrap;html=1;fillColor=#99CCFF;strokeColor=#82b366;fontColor=#000000;</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:attribute name="parent">1</xsl:attribute>
<xsl:attribute name="vertex">1</xsl:attribute>
<xsl:element name="mxGeometry">
<xsl:attribute name="width">120</xsl:attribute>
<xsl:attribute name="height">60</xsl:attribute>
<xsl:attribute name="x"><xsl:value-of select="16 + (24 * position())"/></xsl:attribute>
<xsl:attribute name="y"><xsl:value-of select="(64 * count(/xml[1]/family[child])) + (56 * position())"/></xsl:attribute>
<xsl:attribute name="as">geometry</xsl:attribute>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>