-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformatted.xsl
115 lines (109 loc) · 3.52 KB
/
formatted.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
<?xml version="1.0" ?>
<t:stylesheet version="1.0"
xmlns:t="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
<!-- Elements (formatted) -->
<t:template match="*" mode="formatted">
<t:param name="indent" />
<t:variable name="lang">
<t:call-template name="detect-lang" />
</t:variable>
<t:value-of select="$indent" />
<t:choose>
<t:when test="node()">
<span class="{$lang} element">
<span class="tag start">
<t:text><</t:text>
<t:call-template name="print-name" />
<t:for-each select="@*">
<t:apply-templates select="." mode="formatted" />
</t:for-each>
<t:text>></t:text>
</span>
<t:text>
</t:text>
<t:apply-templates mode="formatted">
<t:with-param name="indent" select="concat($indent, $base-indent)" />
</t:apply-templates>
<t:value-of select="$indent" />
<span class="tag end">
<t:text></</t:text>
<t:value-of select="name(.)"/>
<t:text>></t:text>
</span>
</span>
</t:when>
<t:otherwise>
<span class="{$lang} element empty">
<span class="tag empty">
<t:text><</t:text>
<t:call-template name="print-name" />
<t:for-each select="@*">
<t:apply-templates select="." mode="formatted" />
</t:for-each>
<t:text> /></t:text>
</span>
</span>
</t:otherwise>
</t:choose>
<t:text>
</t:text>
</t:template>
<!-- Attributes (formatted) -->
<t:template match="@*" mode="formatted">
<t:variable name="lang">
<t:call-template name="detect-lang" />
</t:variable>
<t:text> </t:text>
<span class="{$lang} attribute">
<t:call-template name="print-name" />
<t:text>="</t:text>
<span class="attribute-value">
<t:call-template name="parse-attval" />
</span>
<t:text>"</t:text>
</span>
</t:template>
<!-- Processing Instructions (formatted) -->
<t:template match="processing-instruction()" mode="formatted">
<t:param name="indent" />
<t:value-of select="$indent" />
<span class="processing-instruction">
<t:text><?</t:text>
<t:value-of select="name(.)" />
<t:text> </t:text>
<t:call-template name="format-text">
<t:with-param name="text" select="." />
<t:with-param name="indent" select="$indent" />
</t:call-template>
<t:text>?></t:text>
</span>
<t:text>
</t:text>
</t:template>
<!-- Comments (formatted) -->
<t:template match="comment()" mode="formatted">
<t:param name="indent" />
<t:value-of select="$indent" />
<span class="comment">
<t:text><!--</t:text>
<t:call-template name="format-text">
<t:with-param name="text" select="." />
<t:with-param name="indent" select="$indent" />
</t:call-template>
<t:text>--></t:text>
</span>
<t:text>
</t:text>
</t:template>
<!-- Text (formatted) -->
<t:template match="text()" mode="formatted">
<t:param name="indent" />
<t:if test="normalize-space()">
<t:value-of select="$indent" />
<span class="text">
<t:call-template name="format-text">
<t:with-param name="text" select="." />
<t:with-param name="indent" select="$indent" />
</t:call-template>
</span>
<t:text>
</t:text>
</t:if>
</t:template>
</t:stylesheet>