summaryrefslogtreecommitdiffstats
path: root/xml/assets/view-source-original.xsl
blob: 327e0d38bc2669cfc19f8652b1d3cfae8c38f435 (plain)
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
<?xml version="1.0" ?>
<!--
 This file was obtained from https://github.com/Boldewyn/view-source project:
 https://raw.githubusercontent.com/Boldewyn/view-source/f425605366b9f5a52e6a71632785d6e4543c705e/original.xsl

 Licensing governed with:
 https://github.com/Boldewyn/view-source/blob/f425605366b9f5a52e6a71632785d6e4543c705e/README

 > The stylesheet is published under an MIT-style license and the GPL v2.
 > Choose at your liking.

 -->
<t:stylesheet version="1.0"
  xmlns:t="http://www.w3.org/1999/XSL/Transform"
  xmlns="http://www.w3.org/1999/xhtml">

  <!-- Elements (original) -->
  <t:template match="*" mode="original">
    <t:variable name="lang">
      <t:call-template name="detect-lang" />
    </t:variable>
    <t:choose>
      <t:when test="node()">
        <span class="{$lang} element">
          <span class="tag start">
            <t:text>&lt;</t:text>
            <t:call-template name="print-name" />
            <t:for-each select="@*">
              <t:apply-templates select="." mode="original" />
            </t:for-each>
            <t:text>&gt;</t:text>
          </span>
          <t:apply-templates mode="original" />
          <span class="tag end">
            <t:text>&lt;/</t:text>
            <t:value-of select="name(.)"/>
            <t:text>&gt;</t:text>
          </span>
        </span>
      </t:when>
      <t:otherwise>
        <span class="{$lang} element empty">
          <span class="tag empty">
            <t:text>&lt;</t:text>
            <t:call-template name="print-name" />
            <t:for-each select="@*">
              <t:apply-templates select="." mode="original" />
            </t:for-each>
            <t:text> /&gt;</t:text>
          </span>
        </span>
      </t:otherwise>
    </t:choose>
  </t:template>

  <!-- Attributes (original) -->
  <t:template match="@*" mode="original">
    <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 (original) -->
  <t:template match="processing-instruction()" mode="original">
    <span class="processing-instruction">
      <t:text>&lt;?</t:text>
      <t:value-of select="name(.)" />
      <t:text> </t:text>
      <t:value-of select="." />
      <t:text>?&gt;</t:text>
    </span>
  </t:template>

  <!-- Comments (original) -->
  <t:template match="comment()" mode="original">
    <span class="comment">
      <t:text>&lt;!--</t:text>
      <t:call-template name="quote">
        <t:with-param name="text" select="." />
      </t:call-template>
      <t:text>--></t:text>
    </span>
  </t:template>

  <!-- Text (original) -->
  <t:template match="text()" mode="original">
    <span class="text">
      <t:call-template name="quote">
        <t:with-param name="text" select="." />
      </t:call-template>
    </span>
  </t:template>

</t:stylesheet>