File: vc_tree.xml

package info (click to toggle)
virtuoso-opensource 6.1.4%2Bdfsg1-7
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 245,116 kB
  • sloc: ansic: 639,631; sql: 439,225; xml: 287,085; java: 61,048; sh: 38,723; cpp: 36,889; cs: 25,240; php: 12,562; yacc: 9,036; lex: 7,149; makefile: 6,093; jsp: 4,447; awk: 1,643; perl: 1,017; ruby: 1,003; python: 329
file content (308 lines) | stat: -rw-r--r-- 12,337 bytes parent folder | download | duplicates (2)
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
<refentry id="vc_tree">
  <refmeta>
  <refentrytitle>tree</refentrytitle>
  <refmiscinfo>vspx_control</refmiscinfo>
  </refmeta>
  <refnamediv>
  <refname>tree</refname>
  <refpurpose>A container for displaying a tree of nested nodes.</refpurpose>
  </refnamediv>
  <refsynopsisdiv>
   <funcsynopsis id="vc_syn_tree">
    <funcprototype id="vc_proto_tree">
      <funcdef>
            &lt;<function>tree</function> <attribute>
          <parameter>name</parameter> (required) </attribute>
        <attribute>
          <parameter>annotation</parameter> (optional) </attribute>
        <attribute>
          <parameter>initial-enable</parameter> (optional) </attribute>
        <attribute>
          <parameter>enabled</parameter> (optional) </attribute>
        <attribute>
          <parameter>instantiate</parameter> (optional) </attribute>
        <attribute>
          <parameter>control-udt</parameter> (optional) </attribute>
        <attribute>
          <parameter>xsd-stub-xhtml</parameter> (optional) </attribute>
        <attribute>
          <parameter>width</parameter> (optional) </attribute>
        <attribute>
          <parameter>height</parameter> (optional) </attribute>
        <attribute>
          <parameter>show-root</parameter> (optional) </attribute>
        <attribute>
          <parameter>multi-branch</parameter> (required) </attribute>
        <attribute>
          <parameter>orientation</parameter> (required) </attribute>
        <attribute>
          <parameter>root</parameter> (required) </attribute>
        <attribute>
          <parameter>child-function</parameter> (required) </attribute>
        <attribute>
          <parameter>start-path</parameter> (required) </attribute>
        <attribute>
          <parameter>open-at</parameter> (optional) </attribute>
        <attribute>
          <parameter>debug-srcfile</parameter> (optional) </attribute>
        <attribute>
          <parameter>debug-srcline</parameter> (optional) </attribute>
        <attribute>
          <parameter>debug-log</parameter> (optional) </attribute>
 /&gt;</funcdef>
    </funcprototype>
   </funcsynopsis>
  </refsynopsisdiv>
  <refsect1 id="vc_desc_tree">
  <title>Description</title>
  <para>
    <para>This can be used for hierarchical tables of contents,
    directory browsing, hierarchical menus and such.
    The tree can have either one or more branches open at any time, up to
    the leaves.  The tree has a root, which may or may not be visible.
    The contents of the tree can either be fixed, in which case these are an
    XML tree, or dynamic, in which case these are generated level by level
    by SQL functions attached to the tree. The tree can have various external appearences.</para>

    <para>The tree is represented at run time by a vspx_tree instance.
    Nodes of the tree are represented by vspx_tree_node objects,
    which are childs of the vspx_tree.  The nodes hold an identifier (vc_instance_name)
    of the corresponding tree branch, which is used to retrieve children of the node.
    These also hold a flag (tn_open member) indicating if the node is open or not.</para>
			</para>
  </refsect1>
  <refsect1 id="vc_attrs_tree">
  <title>Attributes</title>
  <formalpara>
   <title>name = <link linkend="vc_type_SqlName">SqlName</link>
   </title>
    <para>A page level unique name identifying a control.</para>
  </formalpara>
  <formalpara>
    <title>annotation</title>
    <para>A human readable comment.</para>
  </formalpara>
  <formalpara>
   <title>initial-enable = <link linkend="vc_type_CalculateableValue">CalculateableValue</link>
   </title>
    <para>Determines  whether  a control is initially visible. True by default. Could be data-bound to an SQL expression.</para>
  </formalpara>
  <formalpara>
   <title>enabled = <link linkend="vc_type_CalculateableValue">CalculateableValue</link>
   </title>
    <para>Determines  whether  a control is visible. True by default. Could be data-bound to an SQL expression.</para>
  </formalpara>
  <formalpara>
   <title>instantiate = <link linkend="vc_type_CalculateableValue">CalculateableValue</link>
   </title>
    <para>Determines whether a control instantiate its children. It is true by default. It could be data-bound to an SQL expression. Unlike most of calcucateable attributes, the value of this attribute for a control is calcluated before calling &#39;on-init&#39; event handler of the control; other values are calculated before calling &#39;before-data-bind&#39; event handler.</para>
  </formalpara>
  <formalpara>
   <title>control-udt = <link linkend="vc_type_SqlName">SqlName</link>
   </title>
    <para>At run time every control is represented as an instance of some user-defined type (UDT). VSPX compiles selects the UDT to use depending on name of the XML element that represents the control and maybe some of its attributes. In some specific cases the application developer may instruct VSPX compiler to use some other UDT, e.g. an application-specific UDT that is derived from the preset one. If specified, the value of &#39;control-udt&#39; attribute should be equal to the name of the desired target UDT.</para>
  </formalpara>
  <formalpara>
    <title>xsd-stub-xhtml</title>
    <para>This attribute is for internal use only. It has no effect if added to the source VSPX file.</para>
  </formalpara>
  <formalpara>
    <title>width</title>
    <para>Visible width of the control when it is displayed in WYSIWYG tools when the source VSPX text is edited.
The value of this attribute will not be used when the resulting HTML is rendered.</para>
  </formalpara>
  <formalpara>
    <title>height</title>
    <para>Visible width of the control when it is displayed in WYSIWYG tools when the source VSPX text is edited.
The value of this attribute will not be used when the resulting HTML is rendered.</para>
  </formalpara>
  <formalpara>
    <title>show-root</title>
    <para>This attribute is obsolete and has no effect.</para>
  </formalpara>
  <formalpara>
    <title>multi-branch</title>
    <para>
This determines whether more than one branches can be open at one time.
The values are 0 and 1 (true and false).  The default is 0 (false).
			   </para>
  </formalpara>
  <formalpara>
    <title>orientation</title>
    <para>
      This can be &#39;horizontal&#39; or &#39;vertical&#39;, the default is &#39;vertical&#39;.
      The tree can have different styles.  The default is a vertical arrangement
      with open levels indented, the children under the parent node.
      Each node template is a single line.  The horizontal style shows each level on a separate line.
      In this case it is not allowed multiple open branches.  The children of the root will be
      shown on one line.  When one is opened, its children will fill the next line.
			   </para>
  </formalpara>
  <formalpara>
   <title>root = <link linkend="vc_type_SqlName">SqlName</link>
   </title>
    <para>
This is a SQL expression which produces the root object.
This can be of any data type, a file system path is an example.
</para>
<programlisting>

create procedure root_node (in path varchar)
{
  declare i, l int;
  declare ret, arr any;
  arr :=
    vector_concat (sys_dirlist (path, 0), sys_dirlist (path, 1));

  return arr;
};
</programlisting>
</formalpara>
  <formalpara>
   <title>child-function = <link linkend="vc_type_SqlName">SqlName</link>
   </title>
<para>Given the result of the root expression, this must generate an array
of similar elements corresponing to the children of the node in
question.  This same function should be applicable to each element of
the array it returns.  If the array is empty then the node in question
is a leaf.</para>
<programlisting>


-- Example of this function

create procedure child_node (in node_name varchar, in node varchar)
{
  declare i, l int;
  declare ret, arr any;
  declare exit handler for sqlstate &#39;*&#39;
    {
      return vector ();
    };
  if (isstring (file_stat (node_name, 3)))
    return vector ();

  arr :=
    vector_concat (sys_dirlist (node_name, 0), sys_dirlist (node_name, 1));

  return arr;
}
;
</programlisting>
</formalpara>
  <formalpara>
   <title>start-path = <link linkend="vc_type_CalculateableValue">CalculateableValue</link>
   </title>
    <para>This is an expression which will be evaluated and passed to the &#39;root&#39; function as argument.
                    </para>
  </formalpara>
  <formalpara>
   <title>open-at = <link linkend="vc_type_CalculateableValue">CalculateableValue</link>
   </title>
    <para>This is an expression which will be used as XPath
	    expression to designate which branches of the tree are open
	    and which are not initially.
                    </para>
  </formalpara>
  <formalpara>
    <title>debug-srcfile</title>
    <para>URI of the source document where the tag comes from.</para>
  </formalpara>
  <formalpara>
    <title>debug-srcline</title>
    <para>Line number in the source document where the tag comes from.</para>
  </formalpara>
  <formalpara>
    <title>debug-log</title>
    <para>This defines what sort of data are saved to the debugging log.
</para>
  </formalpara>
  </refsect1>
  <refsect1 id="vc_udt_tree">
  <title>Declaration of type vspx_tree</title>
  <para>
</para>
  <screen>
create type vspx_tree under vspx_control
as
  (
    vt_current_node int default -1,
    vt_node any default null,
    vt_open_at varchar default null,
    vt_xpath_id varchar default null
  )
temporary self as ref
overriding method vc_view_state (stream any, n int) returns any,
method vc_get_state () returns any,
method vc_open_at (path varchar) returns any,
constructor method vspx_tree (name varchar, parent vspx_control)
</screen>
  </refsect1>
  <refsect1 id="vc_ex_tree">
  <title>Examples</title>
   <example id="vc_ex_tree__0">
    <title>
</title>
    <para>
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;!--
 -  
 -  $Id: tree__0.vspx,v 1.2 2006/08/16 00:04:15 source Exp $
 -
 -  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
 -  project.
 -  
 -  Copyright (C) 1998-2006 OpenLink Software
 -  
 -  This project is free software; you can redistribute it and/or modify it
 -  under the terms of the GNU General Public License as published by the
 -  Free Software Foundation; only version 2 of the License, dated June 1991.
 -  
 -  This program is distributed in the hope that it will be useful, but
 -  WITHOUT ANY WARRANTY; without even the implied warranty of
 -  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 -  General Public License for more details.
 -  
 -  You should have received a copy of the GNU General Public License along
 -  with this program; if not, write to the Free Software Foundation, Inc.,
 -  51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 -  
 -  

</para>
    <screen>
&lt;v:page name=&quot;demo_tree&quot; xmlns:v=&quot;http://www.openlinksw.com/vspx/&quot;&gt;
&lt;html&gt;
 &lt;body&gt;
 &lt;v:form name=&quot;f1&quot; method=&quot;POST&quot; type=&quot;simple&quot;&gt;
 &lt;div&gt;
 &lt;v:tree name=&quot;tree1&quot; multi-branch=&quot;1&quot; orientation=&quot;vertical&quot;
         root=&quot;root_node&quot; start-path=&quot;.&quot; child-function=&quot;child_node&quot; &gt;
  &lt;v:node-template name=&quot;node_tmpl&quot;&gt;
    &lt;div STYLE=&quot;margin-left:1em;&quot;&gt;
	&lt;v:button name=&quot;tree1_toggle&quot; action=&quot;simple&quot; style=&quot;image&quot; value=&quot;--case (control.vc_parent as vspx_tree_node).tn_open when 0 then &#39;plus.gif&#39; else &#39;minus.gif&#39; end&quot; /&gt;
	&lt;b&gt;&lt;v:label name=&quot;label1&quot; value=&quot;--(control.vc_parent as vspx_tree_node).tn_value&quot; /&gt;&lt;/b&gt;
	&lt;v:node /&gt;
    &lt;/div&gt;
  &lt;/v:node-template&gt;
  &lt;v:leaf-template name=&quot;leaf_tmpl&quot;&gt;
    &lt;div STYLE=&quot;margin-left:1em;&quot;&gt;
	&lt;v:label name=&quot;label2&quot; value=&quot;--(control.vc_parent as vspx_tree_node).tn_value&quot; /&gt;
    &lt;/div&gt;
  &lt;/v:leaf-template&gt;
 &lt;/v:tree&gt;
 &lt;/div&gt;
 &lt;/v:form&gt;
 &lt;/body&gt;
&lt;/html&gt;
&lt;/v:page&gt;
</screen>
   </example>
  </refsect1>
  <tip>
  <title>See Also: Reference Material in the Tutorial:</title>
   <para>
    <ulink url="/tutorial/web/vx_s_4/tree.vspx">VX-S-4</ulink>
   </para>
  </tip>
</refentry>