-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow_tables.xml
210 lines (191 loc) · 7.29 KB
/
show_tables.xml
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<?xml
version="1.0"
encoding="UTF-8"?>
<?xml-stylesheet
href="xsltforms-1.7/xsltforms.xsl"
type="text/xsl"?>
<?xsltforms-options
debug="no"?>
<html
lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ht="http://www.w3.org/1999/xhtml"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:ui="urn:app.model.ui"
xmlns:dc="http://purl.org/dc/elements/1.1/"
ui:dummy="dummy"
xlink:dummy="dummy">
<dc:title> Example XForms single page app to display a tree-like structure </dc:title>
<dc:creator>midijohnny</dc:creator>
<dc:description>
This is an example single page app that displays a two-level tree structure
The data rendered is an XML representation of the well-known relational database schema 'chinook'.
The version differs from the previous version in that it uses an XSLT stylesheet to decorate the input document with 'ui:*' attributes.
These 'ui:*' attributes are used to keep track of the state of the tree - whether the nodes are expanded, what icon to display for each node.
Using the XSLT stylesheet to do this requires using XSLTForms version 1.7 - which provided the 'setnode' action and the 'transform' function.
The 'ui:dummy' and 'xlink:dummy' attributes defined on the 'html' element are to force Firefox to handle the namespaced attributes used in the instance documents.
See: https://en.wikibooks.org/wiki/XRX/XSLTForms_and_eXist
</dc:description>
<head>
<title>DB Browser Demo</title>
<meta
charset="utf-8"/>
<meta
name="viewport"
content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"/>
<style>
<![CDATA[
ul { list-style-type: none; padding-left: 20px; }
li { list-style-type: none; }
li.collapsed > ul { display: none; }
li.expanded > ul { display: block; }
#r_tables > xforms-repeat-item[xf-selected='false'] { filter: invert(25%); }
]]>
</style>
<xf:model id="model">
<xf:instance id="app" src="app.xml"/>
<xf:instance id="themes" src="themes.xml"/>
<xf:instance id="tables" src="tables.xml"/>
<xf:bind ref="instance('app')">
<xf:bind ref="sidebar/@active" type="xs:boolean"/>
<xf:bind ref="sidebar/@style" calculate="concat('width: ', ../@width, '%;')"/>
<xf:bind ref="main/@style"
calculate="choose(
../../sidebar/@active=true(),
concat('margin-left: ', ../../sidebar/@width, '%;'), '')"/>
</xf:bind>
<xf:bind ref="instance('tables')">
<xf:bind ref="table/sql" readonly="true()"/>
<xf:bind
ref="@ui:icon | table/@ui:icon | table/column/@ui:icon"
calculate="choose(../@ui:expanded ,
choose(../@ui:expanded=true(),
instance('app')/icon[@name=concat(local-name(current()/..),'-','expanded')],
instance('app')/icon[@name=concat(local-name(current()/..),'-','collapsed')]),
choose(../@pk='1',
instance('app')/icon[@name=concat(local-name(current()/..),'-','pk')],
instance('app')/icon[@name=concat(local-name(current()/..),'-','normal')])
)"/>
<xf:bind
ref="//@ui:class"
calculate="choose(../@ui:expanded=true(),
'expanded',
'collapsed')"/>
</xf:bind>
<xf:action ev:event="xforms-ready">
<!-- Add @ui:* attributes to 'table' and 'column' elements in model -->
<!-- The @ui:* attributes are used to track whether a node is expanded/collapsed, icon, visibiilty etc -->
<!-- Now using an XSLT to perform this - more suitable for this task -->
<xf:setnode
ref="instance('tables')"
outer="transform(instance('tables'), 'add_attribs.xsl', false)"/>
<xf:setvalue
ref="instance('app')/@theme"
value="instance('themes')/theme[1]/@xlink:href"/>
</xf:action>
<xf:setvalue
ev:event="toggle-sidebar"
ref="instance('app')/sidebar/@active"
value="choose(.=true(), false(), true())"/>
<xf:setvalue ev:event="next-theme"
ref="instance('app')/@theme"
value="choose(
boolean(instance('themes')/theme[@xlink:href=instance('app')/@theme]/following-sibling::theme),
instance('themes')/theme[@xlink:href=instance('app')/@theme]/following-sibling::theme/@xlink:href,
instance('themes')/theme[1]/@xlink:href)"/>
<xf:setindex
ev:event="next-table"
repeat="r_tables"
index="choose(index('r_tables')=count(instance('tables')/table), 1, 1+index('r_tables'))"/>
<xf:setindex
ev:event="previous-table"
repeat="r_tables"
index="choose(index('r_tables')=1, 1+count(instance('tables')/table), index('r_tables')-1)"/>
</xf:model>
</head>
<body>
<xf:group ref="instance('app')">
<link rel="stylesheet" href="{concat(instance('themes')/@baseurl, @theme)}"/>
<xf:group ref="header">
<header class="{@class}">
<xf:repeat ref="menu/menuitem" id="r_menuitems">
<xf:trigger appearance="minimal" style="display: block">
<xf:output ref="../../../icon[@name=current()/@ui:icon]" class="w3-left w3-button"/>
<xf:dispatch ev:event="DOMActivate" targetid="model">
<xf:name value="instance('app')/header/menu/menuitem[index('r_menuitems')]/@ui:action"/>
</xf:dispatch>
</xf:trigger>
</xf:repeat>
<h1 class="w3-center"><xf:output ref="@title"/></h1>
</header>
</xf:group>
<xf:group ref="sidebar[@active=true()]">
<aside class="{@class}" style="{@style}">
<h1 class="w3-center"><xf:output ref="@title"/></h1>
<nav>
<xf:select1 ref="../@theme" class="w3-bar-item w3-button">
<xf:label>Select Theme:</xf:label>
<xf:itemset ref="instance('themes')/theme/@xlink:href">
<xf:label ref="."/>
<xf:value value="concat(../@baseurl,.)"/>
</xf:itemset>
</xf:select1>
<xf:group ref="instance('tables')">
<ul>
<li class="{@ui:class}">
<xf:trigger appearance="minimal">
<xf:output value="concat(@ui:icon, ' ', 'tables')" style="cursor: pointer" />
<xf:setvalue
ev:event="DOMActivate"
ref="@ui:expanded"
value="choose(.=true(), false(), true())"/>
</xf:trigger>
<ul>
<xf:repeat id="r_tables" ref="table">
<li class="{@ui:class}">
<xf:trigger appearance="minimal">
<xf:output value="concat(@ui:icon, ' ', @name)" style="cursor: pointer" />
<xf:setvalue
ev:event="DOMActivate"
ref="@ui:expanded"
value="choose(.=true(), false(), true())"/>
</xf:trigger>
<ul>
<xf:repeat id="r_columns" ref="column">
<li class="col">
<xf:repeat id="r_col_info" ref="@name">
<xf:output value="concat(../@ui:icon, ' ', .)" style="cursor: pointer" />
</xf:repeat>
</li>
</xf:repeat>
</ul>
</li>
</xf:repeat>
</ul>
</li>
</ul>
</xf:group>
</nav>
</aside>
</xf:group>
<div class="w3-container">
<xf:group ref="main">
<main style="{@style}" class="{@class}">
<section>
<xf:group ref="instance('tables')/table[index('r_tables')]/sql">
<header class="w3-container w3-theme-d4"><h1><xf:output ref="../@name"/></h1></header>
<pre>
<xf:output ref="."/>
</pre>
</xf:group>
</section>
</main>
</xf:group>
</div>
</xf:group>
</body>
</html>