@epa-wg/custom-element 0.0.11 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/inspectionProfiles/Project_Default.xml +22 -7
- package/.idea/misc.xml +4 -5
- package/.vs/VSWorkspaceState.json +8 -0
- package/.vs/custom-element/FileContentIndex/1487e471-3751-47bc-a499-d78eda924eda.vsidx +0 -0
- package/.vs/custom-element/v17/.wsuo +0 -0
- package/.vs/slnx.sqlite +0 -0
- package/README.md +71 -19
- package/custom-element.js +241 -66
- package/demo/a.html +25 -11
- package/demo/confused.svg +36 -36
- package/demo/dom-merge.html +124 -0
- package/demo/embed-1.html +2 -2
- package/demo/external-template.html +9 -7
- package/demo/hex-grid-dce.html +183 -0
- package/demo/hex-grid-transform.png +0 -0
- package/demo/hex-grid.html +66 -0
- package/demo/html-template.html +125 -12
- package/demo/html-template.xhtml +44 -44
- package/demo/html-template.xml +44 -44
- package/demo/http-request.html +44 -57
- package/demo/local-storage.html +23 -18
- package/demo/location-element.html +59 -58
- package/demo/s.xml +1 -0
- package/demo/s.xslt +159 -0
- package/demo/scoped-css.html +170 -0
- package/demo/ss.html +32 -0
- package/demo/table.xml +24 -24
- package/demo/table.xsl +292 -292
- package/demo/template.xsl +45 -45
- package/demo/tree.xml +24 -24
- package/demo/tree.xsl +32 -32
- package/demo/xhtml-template.xhtml +44 -44
- package/demo/z.html +42 -0
- package/demo/z.xml +60 -0
- package/http-request.js +28 -37
- package/index.html +23 -19
- package/input-text.js +17 -0
- package/local-storage.js +28 -35
- package/location-element.js +15 -16
- package/package.json +1 -1
- package/0/a.html +0 -19
- package/0/a.xml +0 -10
- package/0/a.xsl +0 -66
- package/0/a1.xsl +0 -38
- package/0/ab.xsl +0 -23
- package/0/az.xml +0 -30
- package/0/b.html +0 -90
package/demo/table.xsl
CHANGED
|
@@ -1,293 +1,293 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<xsl:stylesheet version="1.0"
|
|
3
|
-
xmlns="http://www.w3.org/1999/xhtml"
|
|
4
|
-
xmlns:xhtml="http://www.w3.org/1999/xhtml"
|
|
5
|
-
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|
6
|
-
xmlns:func="http://exslt.org/functions"
|
|
7
|
-
xmlns:my="my://own.uri"
|
|
8
|
-
xmlns:xv="http://xmlaspect.org/XmlView"
|
|
9
|
-
xmlns:exslt="http://exslt.org/common"
|
|
10
|
-
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
|
|
11
|
-
exclude-result-prefixes="xhtml exslt msxsl"
|
|
12
|
-
extension-element-prefixes="func"
|
|
13
|
-
>
|
|
14
|
-
<xsl:output
|
|
15
|
-
method="html"
|
|
16
|
-
omit-xml-declaration="yes"
|
|
17
|
-
standalone="yes"
|
|
18
|
-
indent="yes"
|
|
19
|
-
/>
|
|
20
|
-
<!--
|
|
21
|
-
let processor = new XSLTProcessor(); // starts the XSL processor
|
|
22
|
-
processor.setParameter(null, "baseUrl", new URL('./', import.meta.url).pathname);
|
|
23
|
-
-->
|
|
24
|
-
<xsl:param name="url" />
|
|
25
|
-
<xsl:param name="baseUrl" select="substring-before(substring-after(/processing-instruction('xml-stylesheet'),'href="'),'table.xsl"')" />
|
|
26
|
-
<xsl:param name="sort" />
|
|
27
|
-
<!-- select = "exslt:node-set($x) IE compatibility -->
|
|
28
|
-
<msxsl:script language="JScript" implements-prefix="exslt">
|
|
29
|
-
<![CDATA[
|
|
30
|
-
var dd = eval("this['node-set'] = function (x) { return x; }");
|
|
31
|
-
]]>
|
|
32
|
-
</msxsl:script>
|
|
33
|
-
|
|
34
|
-
<xsl:variable name="sorts" select="//xsl:sort" />
|
|
35
|
-
|
|
36
|
-
<func:function name="my:count-elements">
|
|
37
|
-
<func:result select="count(//*)" />
|
|
38
|
-
</func:function>
|
|
39
|
-
|
|
40
|
-
<xsl:template match="/">
|
|
41
|
-
<style>
|
|
42
|
-
body{padding:0;margin:0;}
|
|
43
|
-
table {border-collapse:collapse; width:100%; font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;}
|
|
44
|
-
caption{ text-align:left; }
|
|
45
|
-
th {background-image: linear-gradient(to bottom, #0F1FFF 0%, #AAAACC 100%); font-size:large;}
|
|
46
|
-
tr:nth-child(even) {background-image: linear-gradient(to bottom, rgba(9, 16, 11, 0.2) 0%, rgba(90, 164, 110, 0.1) 100%);}
|
|
47
|
-
tr:nth-child(odd) {background: rgba(255,255,255,0.2);}
|
|
48
|
-
td{font-size:small;border-bottom: none;border-top: none;}
|
|
49
|
-
th a{ color: #FFFF80; text-decoration:none; display:block;}
|
|
50
|
-
th a span{float:left;}
|
|
51
|
-
div>label, div>var{ margin-right:0.5em;}
|
|
52
|
-
|
|
53
|
-
fieldset{border-radius: 1em;border-bottom: none;border-left: none;}
|
|
54
|
-
|
|
55
|
-
/* collapse and select UI */
|
|
56
|
-
fieldset legend label{ cursor:pointer;}
|
|
57
|
-
input[type='checkbox']{ display:none;}
|
|
58
|
-
|
|
59
|
-
input[type='checkbox']:checked+fieldset{ border:2px solid red; }
|
|
60
|
-
input[type='checkbox']:checked+input+fieldset div,
|
|
61
|
-
input[type='checkbox']:checked+input+fieldset legend label.collapse i,
|
|
62
|
-
input[type='checkbox']:checked+fieldset .select i,
|
|
63
|
-
input[type='checkbox']+fieldset .collapse b,
|
|
64
|
-
input[type='checkbox']+fieldset .select b
|
|
65
|
-
{display:none; }
|
|
66
|
-
|
|
67
|
-
input[type='checkbox']:checked+input+fieldset .collapse b,
|
|
68
|
-
input[type='checkbox']+input:checked+fieldset .select b
|
|
69
|
-
{ display:inline;}
|
|
70
|
-
|
|
71
|
-
legend label{ text-shadow: -1px -1px 1px #fff, -1px 0px 1px #fff, 0px -1px 1px #fff, 1px 1px 1px #999, 0px 1px 1px #999, 1px 0px 1px #999, 1px 1px 5px #113;}
|
|
72
|
-
legend label b, legend label i{ margin-right: 0.5em; }
|
|
73
|
-
</style>
|
|
74
|
-
<xsl:variable name="sortedData">
|
|
75
|
-
<xsl:call-template name="StartSort">
|
|
76
|
-
<xsl:with-param name="data" select="*" />
|
|
77
|
-
</xsl:call-template>
|
|
78
|
-
</xsl:variable>
|
|
79
|
-
<div class="XmlViewRendered">
|
|
80
|
-
<xsl:apply-templates select="exslt:node-set($sortedData)" mode="DisplayAs"/>
|
|
81
|
-
</div>
|
|
82
|
-
</xsl:template>
|
|
83
|
-
<xsl:template match="/" priority="-20" name="BodyOnly">
|
|
84
|
-
<xsl:variable name="sortedData">
|
|
85
|
-
<xsl:call-template name="StartSort">
|
|
86
|
-
<xsl:with-param name="data" select="*" />
|
|
87
|
-
</xsl:call-template>
|
|
88
|
-
</xsl:variable>
|
|
89
|
-
<xsl:apply-templates select="exslt:node-set($sortedData)" mode="DisplayAs"/>
|
|
90
|
-
</xsl:template>
|
|
91
|
-
|
|
92
|
-
<xsl:template name="StartSort">
|
|
93
|
-
<xsl:param name="data"/>
|
|
94
|
-
<xsl:param name="sortNode"/>
|
|
95
|
-
<xsl:apply-templates mode="SortData" select="$data">
|
|
96
|
-
<xsl:with-param name="sortNode" select="$sortNode" />
|
|
97
|
-
</xsl:apply-templates>
|
|
98
|
-
</xsl:template>
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
<xsl:template mode="SortData" match="*[*]" name="SortDataDefault">
|
|
103
|
-
<xsl:copy>
|
|
104
|
-
<xsl:copy-of select="@*"/>
|
|
105
|
-
<xsl:apply-templates mode="SortData" select="*">
|
|
106
|
-
<xsl:sort data-type="text" order="ascending" select="@stub-will-be-replaced"/>
|
|
107
|
-
</xsl:apply-templates>
|
|
108
|
-
</xsl:copy>
|
|
109
|
-
</xsl:template>
|
|
110
|
-
|
|
111
|
-
<xsl:template mode="SortData" match="*[not(*)]">
|
|
112
|
-
<xsl:copy><xsl:copy-of select="@*"/><xsl:value-of select="."/></xsl:copy>
|
|
113
|
-
</xsl:template>
|
|
114
|
-
|
|
115
|
-
<!-- skip XmlView injected data from sorting results -->
|
|
116
|
-
<xsl:template mode="SortData" match="*[@priority='100']" priority="300"></xsl:template>
|
|
117
|
-
<xsl:template mode="DisplayAsTable" match="*[@priority='100']" priority="300"></xsl:template>
|
|
118
|
-
|
|
119
|
-
<xsl:template mode="DisplayAs" match="*" ><!-- distinct tags, match to 1st -->
|
|
120
|
-
<xsl:variable name="tagName" select="name()" />
|
|
121
|
-
<xsl:choose>
|
|
122
|
-
<xsl:when test="count( ../*[name()=$tagName]) != 1">
|
|
123
|
-
<xsl:apply-templates select="." mode="DisplayAsTable" />
|
|
124
|
-
</xsl:when>
|
|
125
|
-
<xsl:otherwise>
|
|
126
|
-
<xsl:apply-templates select="." mode="DisplayAsTree" />
|
|
127
|
-
</xsl:otherwise>
|
|
128
|
-
</xsl:choose>
|
|
129
|
-
</xsl:template>
|
|
130
|
-
<xsl:template mode="DisplayAs" match="@*" >
|
|
131
|
-
<b><xsl:value-of select="name()"/></b>=<var><xsl:value-of select="."/></var>
|
|
132
|
-
</xsl:template>
|
|
133
|
-
<xsl:template mode="DisplayAsTree" match="*[not(*)]" priority="20">
|
|
134
|
-
<div><label><xsl:value-of select="name()"/></label>
|
|
135
|
-
<xsl:apply-templates select="@*" mode="DisplayAs"/>
|
|
136
|
-
<var><xsl:value-of select="."/></var>
|
|
137
|
-
</div>
|
|
138
|
-
</xsl:template>
|
|
139
|
-
|
|
140
|
-
<xsl:template mode="DisplayAsTree" match="*" >
|
|
141
|
-
<xsl:variable name="xPath"><xsl:apply-templates mode="xpath" select="."/></xsl:variable>
|
|
142
|
-
<input type="checkbox" id="collapse{$xPath}" class="collapseControl"/>
|
|
143
|
-
<input type="checkbox" id="select{$xPath}"/>
|
|
144
|
-
<fieldset>
|
|
145
|
-
<legend><label for="collapse{$xPath}" class="collapse"><b>▶</b><i>▼</i></label> <label for="select{$xPath}" class="select"><b>✔</b><i>✓</i></label> <xsl:value-of select="name()"/></legend>
|
|
146
|
-
<div>
|
|
147
|
-
<xsl:apply-templates select="." mode="DisplayContent"/>
|
|
148
|
-
</div>
|
|
149
|
-
</fieldset>
|
|
150
|
-
</xsl:template>
|
|
151
|
-
<xsl:template mode="DisplayContent" match="*">
|
|
152
|
-
<xsl:for-each select="@*|*">
|
|
153
|
-
<xsl:variable name="tagName" select="name()"/>
|
|
154
|
-
|
|
155
|
-
<xsl:if test="not(preceding-sibling::*[name()=$tagName])">
|
|
156
|
-
<xsl:apply-templates select="." mode="DisplayAs"/>
|
|
157
|
-
</xsl:if>
|
|
158
|
-
</xsl:for-each>
|
|
159
|
-
<xsl:if test="normalize-space(text()) != '' ">
|
|
160
|
-
<p><xsl:value-of select="text()"/></p>
|
|
161
|
-
</xsl:if>
|
|
162
|
-
</xsl:template>
|
|
163
|
-
|
|
164
|
-
<xsl:template match="*" mode="DisplayAsTable" >
|
|
165
|
-
<xsl:param name="childName" select="name()"/>
|
|
166
|
-
<xsl:variable name="ZZheaders" select="@*|*" /> <!-- first child attributes and its children -->
|
|
167
|
-
<!-- TODO union of unique child names as not all rows have same children set. When sorting the missing attributes changing number of columns -->
|
|
168
|
-
<xsl:variable name="collection" select=".."/>
|
|
169
|
-
<xsl:variable name="collectionPath"><xsl:apply-templates mode="xpath" select=".."></xsl:apply-templates></xsl:variable>
|
|
170
|
-
|
|
171
|
-
<xsl:variable name="hAll">
|
|
172
|
-
<xsl:for-each select="*|@*">
|
|
173
|
-
<xsl:variable name="p" select="name()"/>
|
|
174
|
-
<xsl:choose>
|
|
175
|
-
<xsl:when test="count(.|../@*)=count(../@*)"><xsl:element name="{$p}"><xsl:attribute name="xv" ><xsl:value-of select="$p" /></xsl:attribute></xsl:element></xsl:when>
|
|
176
|
-
<xsl:when test="count( preceding-sibling::*[name()=$p]) != 0"></xsl:when>
|
|
177
|
-
<xsl:otherwise><xsl:copy/></xsl:otherwise>
|
|
178
|
-
</xsl:choose>
|
|
179
|
-
</xsl:for-each>
|
|
180
|
-
</xsl:variable>
|
|
181
|
-
<xsl:variable name="headers" select="exslt:node-set($hAll)/*" />
|
|
182
|
-
<table border="1">
|
|
183
|
-
<caption><!-- todo collapsible -->
|
|
184
|
-
<var>
|
|
185
|
-
<xsl:attribute name="title"><xsl:value-of select="$collectionPath"/>/<xsl:value-of select="$childName"/></xsl:attribute>
|
|
186
|
-
<xsl:value-of select="$childName"/>
|
|
187
|
-
</var>
|
|
188
|
-
</caption>
|
|
189
|
-
<thead>
|
|
190
|
-
<tr>
|
|
191
|
-
<xsl:for-each select="$headers">
|
|
192
|
-
<xsl:variable name="p" ><xsl:if test="name(.)=@xv">@</xsl:if><xsl:value-of select="local-name()"/></xsl:variable>
|
|
193
|
-
<xsl:variable name="fullPath" ><xsl:value-of select="$collectionPath"/>/<xsl:value-of select="$p"/></xsl:variable>
|
|
194
|
-
<xsl:variable name ="direction" >
|
|
195
|
-
<xsl:for-each select="$sorts">
|
|
196
|
-
<xsl:if test="@select=$p">
|
|
197
|
-
<xsl:choose>
|
|
198
|
-
<xsl:when test="@order='ascending'">▲</xsl:when>
|
|
199
|
-
<xsl:when test="@order='descending'">▼</xsl:when>
|
|
200
|
-
<xsl:otherwise>◊</xsl:otherwise>
|
|
201
|
-
</xsl:choose>
|
|
202
|
-
</xsl:if>
|
|
203
|
-
</xsl:for-each>
|
|
204
|
-
</xsl:variable>
|
|
205
|
-
<xsl:variable name ="order" >
|
|
206
|
-
<xsl:for-each select="$sorts">
|
|
207
|
-
<xsl:if test="@select=$p">
|
|
208
|
-
<xsl:value-of select="count(preceding-sibling::xsl:sort) "/>
|
|
209
|
-
</xsl:if>
|
|
210
|
-
</xsl:for-each>
|
|
211
|
-
</xsl:variable>
|
|
212
|
-
|
|
213
|
-
<th><a href="#"
|
|
214
|
-
title="{$p}"
|
|
215
|
-
xv:sortpath="{$p}"
|
|
216
|
-
><span><xsl:value-of select="$direction"/> <sub><xsl:value-of select="$order"/> </sub></span>
|
|
217
|
-
|
|
218
|
-
<xsl:value-of select="local-name()"/>
|
|
219
|
-
</a>
|
|
220
|
-
</th>
|
|
221
|
-
</xsl:for-each>
|
|
222
|
-
</tr>
|
|
223
|
-
</thead>
|
|
224
|
-
<tbody>
|
|
225
|
-
<xsl:for-each select="../*[name()=$childName]">
|
|
226
|
-
<xsl:variable name="rowNode" select="." />
|
|
227
|
-
<tr>
|
|
228
|
-
<xsl:for-each select="$headers">
|
|
229
|
-
<xsl:variable name="key" select="name()" />
|
|
230
|
-
<td>
|
|
231
|
-
<!-- xsl:attribute name="title"><xsl:apply-templates mode="xpath" select="."></xsl:apply-templates></xsl:attribute -->
|
|
232
|
-
|
|
233
|
-
<xsl:choose>
|
|
234
|
-
<xsl:when test="count( $rowNode/*[name()=$key]) > 1">
|
|
235
|
-
<xsl:apply-templates select="$rowNode/*[name()=$key][1]" mode="DisplayAsTable" />
|
|
236
|
-
</xsl:when>
|
|
237
|
-
<xsl:otherwise>
|
|
238
|
-
<xsl:apply-templates mode="DisplayContent" select="$rowNode/*[name()=$key]|$rowNode/@*[name()=$key]" />
|
|
239
|
-
</xsl:otherwise>
|
|
240
|
-
</xsl:choose>
|
|
241
|
-
|
|
242
|
-
</td>
|
|
243
|
-
</xsl:for-each>
|
|
244
|
-
</tr>
|
|
245
|
-
</xsl:for-each>
|
|
246
|
-
</tbody>
|
|
247
|
-
</table>
|
|
248
|
-
</xsl:template>
|
|
249
|
-
|
|
250
|
-
<!-- XmlAspect/XOR/XPath/Dom2XPath.xsl -->
|
|
251
|
-
<!-- Root -->
|
|
252
|
-
<xsl:template match="/" mode="xpath">
|
|
253
|
-
<xsl:text>/</xsl:text>
|
|
254
|
-
</xsl:template>
|
|
255
|
-
|
|
256
|
-
<!-- Element -->
|
|
257
|
-
<xsl:template match="*" mode="xpath">
|
|
258
|
-
<!-- Process ancestors first -->
|
|
259
|
-
<xsl:apply-templates select=".." mode="xpath"/>
|
|
260
|
-
|
|
261
|
-
<!-- Output / if not already output by the root node -->
|
|
262
|
-
<xsl:if test="../..">/</xsl:if>
|
|
263
|
-
|
|
264
|
-
<!-- Output the name of the element -->
|
|
265
|
-
<xsl:value-of select="name()"/>
|
|
266
|
-
|
|
267
|
-
<!-- Add the element's position to pinpoint the element exactly -->
|
|
268
|
-
<xsl:if test="count(../*[name() = name(current())]) > 1">
|
|
269
|
-
<xsl:text>[</xsl:text>
|
|
270
|
-
<xsl:value-of
|
|
271
|
-
select="count(preceding-sibling::*[name() = name(current())]) +1"/>
|
|
272
|
-
<xsl:text>]</xsl:text>
|
|
273
|
-
</xsl:if>
|
|
274
|
-
|
|
275
|
-
<!-- Add 'name' predicate as a hint of which element -->
|
|
276
|
-
<xsl:if test="@name">
|
|
277
|
-
<xsl:text/>[@name="<xsl:value-of select="@name"/>"]<xsl:text/>
|
|
278
|
-
</xsl:if>
|
|
279
|
-
</xsl:template>
|
|
280
|
-
|
|
281
|
-
<!-- Attribute -->
|
|
282
|
-
<xsl:template match="@*" mode="xpath">
|
|
283
|
-
<!-- Process ancestors first -->
|
|
284
|
-
<xsl:apply-templates select=".." mode="xpath"/>
|
|
285
|
-
|
|
286
|
-
<!-- Output the name of the attribute -->
|
|
287
|
-
<xsl:text/>/@<xsl:value-of select="name()"/>
|
|
288
|
-
|
|
289
|
-
<!-- Output the attribute's value as a predicate -->
|
|
290
|
-
<xsl:text/>[.="<xsl:value-of select="."/>"]<xsl:text/>
|
|
291
|
-
</xsl:template>
|
|
292
|
-
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<xsl:stylesheet version="1.0"
|
|
3
|
+
xmlns="http://www.w3.org/1999/xhtml"
|
|
4
|
+
xmlns:xhtml="http://www.w3.org/1999/xhtml"
|
|
5
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|
6
|
+
xmlns:func="http://exslt.org/functions"
|
|
7
|
+
xmlns:my="my://own.uri"
|
|
8
|
+
xmlns:xv="http://xmlaspect.org/XmlView"
|
|
9
|
+
xmlns:exslt="http://exslt.org/common"
|
|
10
|
+
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
|
|
11
|
+
exclude-result-prefixes="xhtml exslt msxsl"
|
|
12
|
+
extension-element-prefixes="func"
|
|
13
|
+
>
|
|
14
|
+
<xsl:output
|
|
15
|
+
method="html"
|
|
16
|
+
omit-xml-declaration="yes"
|
|
17
|
+
standalone="yes"
|
|
18
|
+
indent="yes"
|
|
19
|
+
/>
|
|
20
|
+
<!--
|
|
21
|
+
let processor = new XSLTProcessor(); // starts the XSL processor
|
|
22
|
+
processor.setParameter(null, "baseUrl", new URL('./', import.meta.url).pathname);
|
|
23
|
+
-->
|
|
24
|
+
<xsl:param name="url" />
|
|
25
|
+
<xsl:param name="baseUrl" select="substring-before(substring-after(/processing-instruction('xml-stylesheet'),'href="'),'table.xsl"')" />
|
|
26
|
+
<xsl:param name="sort" />
|
|
27
|
+
<!-- select = "exslt:node-set($x) IE compatibility -->
|
|
28
|
+
<msxsl:script language="JScript" implements-prefix="exslt">
|
|
29
|
+
<![CDATA[
|
|
30
|
+
var dd = eval("this['node-set'] = function (x) { return x; }");
|
|
31
|
+
]]>
|
|
32
|
+
</msxsl:script>
|
|
33
|
+
|
|
34
|
+
<xsl:variable name="sorts" select="//xsl:sort" />
|
|
35
|
+
|
|
36
|
+
<func:function name="my:count-elements">
|
|
37
|
+
<func:result select="count(//*)" />
|
|
38
|
+
</func:function>
|
|
39
|
+
|
|
40
|
+
<xsl:template match="/">
|
|
41
|
+
<style>
|
|
42
|
+
body{padding:0;margin:0;}
|
|
43
|
+
table {border-collapse:collapse; width:100%; font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;}
|
|
44
|
+
caption{ text-align:left; }
|
|
45
|
+
th {background-image: linear-gradient(to bottom, #0F1FFF 0%, #AAAACC 100%); font-size:large;}
|
|
46
|
+
tr:nth-child(even) {background-image: linear-gradient(to bottom, rgba(9, 16, 11, 0.2) 0%, rgba(90, 164, 110, 0.1) 100%);}
|
|
47
|
+
tr:nth-child(odd) {background: rgba(255,255,255,0.2);}
|
|
48
|
+
td{font-size:small;border-bottom: none;border-top: none;}
|
|
49
|
+
th a{ color: #FFFF80; text-decoration:none; display:block;}
|
|
50
|
+
th a span{float:left;}
|
|
51
|
+
div>label, div>var{ margin-right:0.5em;}
|
|
52
|
+
|
|
53
|
+
fieldset{border-radius: 1em;border-bottom: none;border-left: none;}
|
|
54
|
+
|
|
55
|
+
/* collapse and select UI */
|
|
56
|
+
fieldset legend label{ cursor:pointer;}
|
|
57
|
+
input[type='checkbox']{ display:none;}
|
|
58
|
+
|
|
59
|
+
input[type='checkbox']:checked+fieldset{ border:2px solid red; }
|
|
60
|
+
input[type='checkbox']:checked+input+fieldset div,
|
|
61
|
+
input[type='checkbox']:checked+input+fieldset legend label.collapse i,
|
|
62
|
+
input[type='checkbox']:checked+fieldset .select i,
|
|
63
|
+
input[type='checkbox']+fieldset .collapse b,
|
|
64
|
+
input[type='checkbox']+fieldset .select b
|
|
65
|
+
{display:none; }
|
|
66
|
+
|
|
67
|
+
input[type='checkbox']:checked+input+fieldset .collapse b,
|
|
68
|
+
input[type='checkbox']+input:checked+fieldset .select b
|
|
69
|
+
{ display:inline;}
|
|
70
|
+
|
|
71
|
+
legend label{ text-shadow: -1px -1px 1px #fff, -1px 0px 1px #fff, 0px -1px 1px #fff, 1px 1px 1px #999, 0px 1px 1px #999, 1px 0px 1px #999, 1px 1px 5px #113;}
|
|
72
|
+
legend label b, legend label i{ margin-right: 0.5em; }
|
|
73
|
+
</style>
|
|
74
|
+
<xsl:variable name="sortedData">
|
|
75
|
+
<xsl:call-template name="StartSort">
|
|
76
|
+
<xsl:with-param name="data" select="*" />
|
|
77
|
+
</xsl:call-template>
|
|
78
|
+
</xsl:variable>
|
|
79
|
+
<div class="XmlViewRendered">
|
|
80
|
+
<xsl:apply-templates select="exslt:node-set($sortedData)" mode="DisplayAs"/>
|
|
81
|
+
</div>
|
|
82
|
+
</xsl:template>
|
|
83
|
+
<xsl:template match="/" priority="-20" name="BodyOnly">
|
|
84
|
+
<xsl:variable name="sortedData">
|
|
85
|
+
<xsl:call-template name="StartSort">
|
|
86
|
+
<xsl:with-param name="data" select="*" />
|
|
87
|
+
</xsl:call-template>
|
|
88
|
+
</xsl:variable>
|
|
89
|
+
<xsl:apply-templates select="exslt:node-set($sortedData)" mode="DisplayAs"/>
|
|
90
|
+
</xsl:template>
|
|
91
|
+
|
|
92
|
+
<xsl:template name="StartSort">
|
|
93
|
+
<xsl:param name="data"/>
|
|
94
|
+
<xsl:param name="sortNode"/>
|
|
95
|
+
<xsl:apply-templates mode="SortData" select="$data">
|
|
96
|
+
<xsl:with-param name="sortNode" select="$sortNode" />
|
|
97
|
+
</xsl:apply-templates>
|
|
98
|
+
</xsl:template>
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
<xsl:template mode="SortData" match="*[*]" name="SortDataDefault">
|
|
103
|
+
<xsl:copy>
|
|
104
|
+
<xsl:copy-of select="@*"/>
|
|
105
|
+
<xsl:apply-templates mode="SortData" select="*">
|
|
106
|
+
<xsl:sort data-type="text" order="ascending" select="@stub-will-be-replaced"/>
|
|
107
|
+
</xsl:apply-templates>
|
|
108
|
+
</xsl:copy>
|
|
109
|
+
</xsl:template>
|
|
110
|
+
|
|
111
|
+
<xsl:template mode="SortData" match="*[not(*)]">
|
|
112
|
+
<xsl:copy><xsl:copy-of select="@*"/><xsl:value-of select="."/></xsl:copy>
|
|
113
|
+
</xsl:template>
|
|
114
|
+
|
|
115
|
+
<!-- skip XmlView injected data from sorting results -->
|
|
116
|
+
<xsl:template mode="SortData" match="*[@priority='100']" priority="300"></xsl:template>
|
|
117
|
+
<xsl:template mode="DisplayAsTable" match="*[@priority='100']" priority="300"></xsl:template>
|
|
118
|
+
|
|
119
|
+
<xsl:template mode="DisplayAs" match="*" ><!-- distinct tags, match to 1st -->
|
|
120
|
+
<xsl:variable name="tagName" select="name()" />
|
|
121
|
+
<xsl:choose>
|
|
122
|
+
<xsl:when test="count( ../*[name()=$tagName]) != 1">
|
|
123
|
+
<xsl:apply-templates select="." mode="DisplayAsTable" />
|
|
124
|
+
</xsl:when>
|
|
125
|
+
<xsl:otherwise>
|
|
126
|
+
<xsl:apply-templates select="." mode="DisplayAsTree" />
|
|
127
|
+
</xsl:otherwise>
|
|
128
|
+
</xsl:choose>
|
|
129
|
+
</xsl:template>
|
|
130
|
+
<xsl:template mode="DisplayAs" match="@*" >
|
|
131
|
+
<b><xsl:value-of select="name()"/></b>=<var><xsl:value-of select="."/></var>
|
|
132
|
+
</xsl:template>
|
|
133
|
+
<xsl:template mode="DisplayAsTree" match="*[not(*)]" priority="20">
|
|
134
|
+
<div><label><xsl:value-of select="name()"/></label>
|
|
135
|
+
<xsl:apply-templates select="@*" mode="DisplayAs"/>
|
|
136
|
+
<var><xsl:value-of select="."/></var>
|
|
137
|
+
</div>
|
|
138
|
+
</xsl:template>
|
|
139
|
+
|
|
140
|
+
<xsl:template mode="DisplayAsTree" match="*" >
|
|
141
|
+
<xsl:variable name="xPath"><xsl:apply-templates mode="xpath" select="."/></xsl:variable>
|
|
142
|
+
<input type="checkbox" id="collapse{$xPath}" class="collapseControl"/>
|
|
143
|
+
<input type="checkbox" id="select{$xPath}"/>
|
|
144
|
+
<fieldset>
|
|
145
|
+
<legend><label for="collapse{$xPath}" class="collapse"><b>▶</b><i>▼</i></label> <label for="select{$xPath}" class="select"><b>✔</b><i>✓</i></label> <xsl:value-of select="name()"/></legend>
|
|
146
|
+
<div>
|
|
147
|
+
<xsl:apply-templates select="." mode="DisplayContent"/>
|
|
148
|
+
</div>
|
|
149
|
+
</fieldset>
|
|
150
|
+
</xsl:template>
|
|
151
|
+
<xsl:template mode="DisplayContent" match="*">
|
|
152
|
+
<xsl:for-each select="@*|*">
|
|
153
|
+
<xsl:variable name="tagName" select="name()"/>
|
|
154
|
+
|
|
155
|
+
<xsl:if test="not(preceding-sibling::*[name()=$tagName])">
|
|
156
|
+
<xsl:apply-templates select="." mode="DisplayAs"/>
|
|
157
|
+
</xsl:if>
|
|
158
|
+
</xsl:for-each>
|
|
159
|
+
<xsl:if test="normalize-space(text()) != '' ">
|
|
160
|
+
<p><xsl:value-of select="text()"/></p>
|
|
161
|
+
</xsl:if>
|
|
162
|
+
</xsl:template>
|
|
163
|
+
|
|
164
|
+
<xsl:template match="*" mode="DisplayAsTable" >
|
|
165
|
+
<xsl:param name="childName" select="name()"/>
|
|
166
|
+
<xsl:variable name="ZZheaders" select="@*|*" /> <!-- first child attributes and its children -->
|
|
167
|
+
<!-- TODO union of unique child names as not all rows have same children set. When sorting the missing attributes changing number of columns -->
|
|
168
|
+
<xsl:variable name="collection" select=".."/>
|
|
169
|
+
<xsl:variable name="collectionPath"><xsl:apply-templates mode="xpath" select=".."></xsl:apply-templates></xsl:variable>
|
|
170
|
+
|
|
171
|
+
<xsl:variable name="hAll">
|
|
172
|
+
<xsl:for-each select="*|@*">
|
|
173
|
+
<xsl:variable name="p" select="name()"/>
|
|
174
|
+
<xsl:choose>
|
|
175
|
+
<xsl:when test="count(.|../@*)=count(../@*)"><xsl:element name="{$p}"><xsl:attribute name="xv" ><xsl:value-of select="$p" /></xsl:attribute></xsl:element></xsl:when>
|
|
176
|
+
<xsl:when test="count( preceding-sibling::*[name()=$p]) != 0"></xsl:when>
|
|
177
|
+
<xsl:otherwise><xsl:copy/></xsl:otherwise>
|
|
178
|
+
</xsl:choose>
|
|
179
|
+
</xsl:for-each>
|
|
180
|
+
</xsl:variable>
|
|
181
|
+
<xsl:variable name="headers" select="exslt:node-set($hAll)/*" />
|
|
182
|
+
<table border="1">
|
|
183
|
+
<caption><!-- todo collapsible -->
|
|
184
|
+
<var>
|
|
185
|
+
<xsl:attribute name="title"><xsl:value-of select="$collectionPath"/>/<xsl:value-of select="$childName"/></xsl:attribute>
|
|
186
|
+
<xsl:value-of select="$childName"/>
|
|
187
|
+
</var>
|
|
188
|
+
</caption>
|
|
189
|
+
<thead>
|
|
190
|
+
<tr>
|
|
191
|
+
<xsl:for-each select="$headers">
|
|
192
|
+
<xsl:variable name="p" ><xsl:if test="name(.)=@xv">@</xsl:if><xsl:value-of select="local-name()"/></xsl:variable>
|
|
193
|
+
<xsl:variable name="fullPath" ><xsl:value-of select="$collectionPath"/>/<xsl:value-of select="$p"/></xsl:variable>
|
|
194
|
+
<xsl:variable name ="direction" >
|
|
195
|
+
<xsl:for-each select="$sorts">
|
|
196
|
+
<xsl:if test="@select=$p">
|
|
197
|
+
<xsl:choose>
|
|
198
|
+
<xsl:when test="@order='ascending'">▲</xsl:when>
|
|
199
|
+
<xsl:when test="@order='descending'">▼</xsl:when>
|
|
200
|
+
<xsl:otherwise>◊</xsl:otherwise>
|
|
201
|
+
</xsl:choose>
|
|
202
|
+
</xsl:if>
|
|
203
|
+
</xsl:for-each>
|
|
204
|
+
</xsl:variable>
|
|
205
|
+
<xsl:variable name ="order" >
|
|
206
|
+
<xsl:for-each select="$sorts">
|
|
207
|
+
<xsl:if test="@select=$p">
|
|
208
|
+
<xsl:value-of select="count(preceding-sibling::xsl:sort) "/>
|
|
209
|
+
</xsl:if>
|
|
210
|
+
</xsl:for-each>
|
|
211
|
+
</xsl:variable>
|
|
212
|
+
|
|
213
|
+
<th><a href="#"
|
|
214
|
+
title="{$p}"
|
|
215
|
+
xv:sortpath="{$p}"
|
|
216
|
+
><span><xsl:value-of select="$direction"/> <sub><xsl:value-of select="$order"/> </sub></span>
|
|
217
|
+
|
|
218
|
+
<xsl:value-of select="local-name()"/>
|
|
219
|
+
</a>
|
|
220
|
+
</th>
|
|
221
|
+
</xsl:for-each>
|
|
222
|
+
</tr>
|
|
223
|
+
</thead>
|
|
224
|
+
<tbody>
|
|
225
|
+
<xsl:for-each select="../*[name()=$childName]">
|
|
226
|
+
<xsl:variable name="rowNode" select="." />
|
|
227
|
+
<tr>
|
|
228
|
+
<xsl:for-each select="$headers">
|
|
229
|
+
<xsl:variable name="key" select="name()" />
|
|
230
|
+
<td>
|
|
231
|
+
<!-- xsl:attribute name="title"><xsl:apply-templates mode="xpath" select="."></xsl:apply-templates></xsl:attribute -->
|
|
232
|
+
|
|
233
|
+
<xsl:choose>
|
|
234
|
+
<xsl:when test="count( $rowNode/*[name()=$key]) > 1">
|
|
235
|
+
<xsl:apply-templates select="$rowNode/*[name()=$key][1]" mode="DisplayAsTable" />
|
|
236
|
+
</xsl:when>
|
|
237
|
+
<xsl:otherwise>
|
|
238
|
+
<xsl:apply-templates mode="DisplayContent" select="$rowNode/*[name()=$key]|$rowNode/@*[name()=$key]" />
|
|
239
|
+
</xsl:otherwise>
|
|
240
|
+
</xsl:choose>
|
|
241
|
+
|
|
242
|
+
</td>
|
|
243
|
+
</xsl:for-each>
|
|
244
|
+
</tr>
|
|
245
|
+
</xsl:for-each>
|
|
246
|
+
</tbody>
|
|
247
|
+
</table>
|
|
248
|
+
</xsl:template>
|
|
249
|
+
|
|
250
|
+
<!-- XmlAspect/XOR/XPath/Dom2XPath.xsl -->
|
|
251
|
+
<!-- Root -->
|
|
252
|
+
<xsl:template match="/" mode="xpath">
|
|
253
|
+
<xsl:text>/</xsl:text>
|
|
254
|
+
</xsl:template>
|
|
255
|
+
|
|
256
|
+
<!-- Element -->
|
|
257
|
+
<xsl:template match="*" mode="xpath">
|
|
258
|
+
<!-- Process ancestors first -->
|
|
259
|
+
<xsl:apply-templates select=".." mode="xpath"/>
|
|
260
|
+
|
|
261
|
+
<!-- Output / if not already output by the root node -->
|
|
262
|
+
<xsl:if test="../..">/</xsl:if>
|
|
263
|
+
|
|
264
|
+
<!-- Output the name of the element -->
|
|
265
|
+
<xsl:value-of select="name()"/>
|
|
266
|
+
|
|
267
|
+
<!-- Add the element's position to pinpoint the element exactly -->
|
|
268
|
+
<xsl:if test="count(../*[name() = name(current())]) > 1">
|
|
269
|
+
<xsl:text>[</xsl:text>
|
|
270
|
+
<xsl:value-of
|
|
271
|
+
select="count(preceding-sibling::*[name() = name(current())]) +1"/>
|
|
272
|
+
<xsl:text>]</xsl:text>
|
|
273
|
+
</xsl:if>
|
|
274
|
+
|
|
275
|
+
<!-- Add 'name' predicate as a hint of which element -->
|
|
276
|
+
<xsl:if test="@name">
|
|
277
|
+
<xsl:text/>[@name="<xsl:value-of select="@name"/>"]<xsl:text/>
|
|
278
|
+
</xsl:if>
|
|
279
|
+
</xsl:template>
|
|
280
|
+
|
|
281
|
+
<!-- Attribute -->
|
|
282
|
+
<xsl:template match="@*" mode="xpath">
|
|
283
|
+
<!-- Process ancestors first -->
|
|
284
|
+
<xsl:apply-templates select=".." mode="xpath"/>
|
|
285
|
+
|
|
286
|
+
<!-- Output the name of the attribute -->
|
|
287
|
+
<xsl:text/>/@<xsl:value-of select="name()"/>
|
|
288
|
+
|
|
289
|
+
<!-- Output the attribute's value as a predicate -->
|
|
290
|
+
<xsl:text/>[.="<xsl:value-of select="."/>"]<xsl:text/>
|
|
291
|
+
</xsl:template>
|
|
292
|
+
|
|
293
293
|
</xsl:stylesheet>
|