File: adminui.querytools.xml

package info (click to toggle)
virtuoso-opensource 7.2.5.1%2Bdfsg1-0.3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 285,240 kB
  • sloc: ansic: 641,220; sql: 490,413; xml: 269,570; java: 83,893; javascript: 79,900; cpp: 36,927; sh: 31,653; cs: 25,702; php: 12,690; yacc: 10,227; lex: 7,601; makefile: 7,129; jsp: 4,523; awk: 1,697; perl: 1,013; ruby: 1,003; python: 326
file content (127 lines) | stat: -rw-r--r-- 5,566 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
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
 -  
 -  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
 -  project.
 -  
 -  Copyright (C) 1998-2018 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
 -  
 -  
-->

<sect2 id="querytools"><title>Query Tools</title>
	<sect3 id="sqlqueries"><title>Relational Data using SQL</title>
	<para>
Conductor Interactive SQL allows you to quickly and directly query Virtuoso using SQL.
It offers <emphasis>Save</emphasis> and <emphasis>Load</emphasis>
facilities which allow SQL queries to be saved as an XML template, and read 
back later.  With a query in the SQL Statement box click on the 
<emphasis>Execute</emphasis> for the results which will in the "Base" tab with option to return back
to the query area. The <emphasis>Clear</emphasis> clears the SQL Statement text box.</para>

        <figure float="1"><title>Querying Relational Database Using SQL</title>
          <graphic fileref="ui/qry_sql_01.png"/></figure>

        <figure float="1"><title>Results</title>
          <graphic fileref="ui/qry_sql_01a.png"/></figure>

<para>Specify the location for the file to be saved to by selecting the "WebDAV source" or "Local file"
check-box. </para>

        <figure float="1"><title>Saving SQL in an XML Template</title>
          <graphic fileref="ui/qry_sql_02.png"/></figure>

<para>Click the "Browse" button. As result will be opened the Virtuoso WebDAV/File Browser
where you should define the XML template based on the SQL Query. Specify a
<emphasis>Root Element</emphasis> that will contain the resulting XML tree.
Specify the file name and location of the XML Template. </para>
  </sect3>
<sect3 id="xqueryqueries"><title>XML Data Using XQuery</title>
<para>
The Conductor Interactive XQuery facility allows you to create,
execute, save and reload queries using the evolving <ulink
url="http://www.w3.org/TR/xquery/">W3C XML Query (XQuery) Language</ulink>.  
Virtuoso currently supports the 1.0 version of this language.
</para>
<para>
This language uses XPath-like expressions, as well as a set of
functions and operators, to permit effective parallel searching of a
set of XML documents.  Where XPath works with one XML &quot;tree&quot;, 
XQuery searches a &quot;forest&quot;.  The result is an XML document.
</para>
<para>
In order to create an XQuery you must both create the query statement
&mdash; by typing or pasting it into the text box &mdash; and specify
the document context.  Since Virtuoso's XQuery implementation operates
over XML data in relational tables, this means the tables and columns
that are to be searched.
</para>
<para>
Note that the XQuery language also allows a query to specify all or
part of the document context for the query.  In the example below we
will see how these can interact.  The user interface form permits you to 
select a table &mdash; either one of the XQuery test data tables that come
with Virtuoso, or the WS.WS.SYS_DAV_RES table, which stores Virtuoso's WebDAV
Repository content.
</para>
<para>
The form specifies a <parameter>Key Column</parameter> and a
<parameter>Data Column</parameter>.  For the sample tables, the values
for these are filled in for you.  The <parameter>Path</parameter> is
prepended to any <function>document()</function> function specified in
the query text to find Key column values of XML trees against which
the query is to be run.
</para>
<para>
Once a query has been written and debugged, it can be saved by
pressing the Save button.  This brings you to the form for saving a
query as an XML Template in the DAV repository.
</para>
<para>
Pressing the Execute button causes the query result (an XML tree) to
be shown on the page below the Statement type-in box.
</para>
<example id="ex_xqtool"><title>XQuery Test File Example</title>
<para>
In this example, we will query the table XQuery test files table, with
&quot;name&quot; as the key column and &quot;text&quot; as the data
column.
</para>
<para>The query text, shown below, is a sample query from the W3C's
XML Query Use Cases document (<ulink
url="http://www.w3.org/TR/xmlquery-use-cases">http://www.w3.org/TR/xmlquery-use-cases</ulink>).
This query contains a document() call specifying a document named
&quot;bib.xml&quot;.  In order to have the query run properly, we
first set the Path form value to &quot;xqdemo/&quot;.  This causes the
query to find all rows in the table XQ.XQ.TEST_FILES that have the
value &quot;xqdemo/bib.xml&quot; in their Name column.</para>
<programlisting><![CDATA[
<bib>
   {
   for $b in document("bib.xml")/bib/book
   where $b/publisher = "Addison-Wesley" and $b/@year > 1991
   return
      <book year = {$b/@year}>
         {$b/title}
      </book>
   }
</bib>
]]></programlisting>
</example>
          <figure float="1"><title>XQuery Test File Results</title>
          <graphic fileref="ui/qry_sql_02a.png"/></figure>
</sect3>
</sect2>