Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[r17268]: apps / doc / data / how-to-learn-xquery.xml Maximize Restore History

Download this file

how-to-learn-xquery.xml    154 lines (152 with data), 9.5 kB

  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
<article>
<!-- Docbook 4 format for now -->
<title>How to Learn XQuery</title>
<sect1>
<title>Key Points to Learning XQuery</title>
<para>This is a guide to help you learn XQuery. It contains some brief background
information on XQuery and then lists a number of resources you can use to learn
XQuery.</para>
<para>XQuery is unique in the development stack in that it replaces both SQL and the
traditional software layers that convert SQL into presentation formats such as HTML, PDF
and ePub. XQuery can both retrieve information from your database and format it for
presentation. </para>
<para>Learning how to select basic data from an XML document can be learned in just a few
hours if you are already familiar with SQL and other functional programming languages.
However, learning how to create custom XQuery functions, how to design XQuery modules
and how to execute unit tests on XQuery takes considerably longer.</para>
<sect2>
<title>Learning by Example</title>
<para>Many people find that they learn a new language best by reading small examples of
code. One of the ideal locations for this is the <ulink
url="http://en.wikibooks.org/wiki/XQuery#Beginning_Examples">XQuery Wikibook
Beginning Examples</ulink>
</para>
<para>These examples are all designed and tested to work with eXist. Please let us know if
there are specific examples you would like to see.</para>
</sect2>
<sect2>
<title>Learning Functional Programming</title>
<para>XQuery is a functional programming language, so many things that you do in
procedural programs are not recommended or not possible. In XQuery all variables
should be immutable, meaning they should be set once but never changed. This aspect
of XQuery allows it to be stateless and side-effect free.</para>
</sect2>
<sect2>
<title>Learning FLOWR statements</title>
<para>Iteration in XQuery uses parallel programming statements called FLOWR statements.
Each loop of a FLOWR statement is performed in a separate thread of execution. As a
result you cannot use the output of any computation in a FLOWR loop as input to the
next loop. This concept can be difficult to learn if you have never used parallel
programming systems.</para>
</sect2>
<sect2>
<title>Learning XPath</title>
<para>XQuery also includes the use of XPath to select various nodes from an XML document. Note
that with native XML databases the shortest XPath expression is often the fastest since
short expressions use element indexes. You may want to use a tool such as an XPath "builder" tool
within an IDE such as oXygen to learn how to build XPath expressions.</para>
</sect2>
<sect2>
<title>Using eXide</title>
<para>eXist comes with a web-based tool for doing XQuery development called eXide.
Although this tool is not as advanced as a full IDE such as oXygen, it is ideal for
small queries if an IDE is not accessible.</para>
</sect2>
<sect2>
<title>Learning how to update XML documents</title>
<para>eXist comes with a set of operations for updating on-disk XML documents.
<ulink url="http://exist-db.org/update_ext.xml">eXist XQuery Update Operations</ulink>
</para>
</sect2>
<sect2>
<title>Learning how to debug XQuery</title>
<para>eXist has some support for step-by-step debugging of XQuery, but the interface is
not mature yet. Many people choose to debug complex recursive functions directly
within XML IDEs such as oXygen that support step-by-step debugging using the
internal Saxon XQuery library. The oXygen IDE allows you to set breakpoints and
watch the output document get created one element at a time. This process is
strongly recommended if you are learning topics like recursion. <ulink
url="http://exist-db.org/exist/debugger.xml">eXist XQuery Debugger</ulink>
</para>
</sect2>
<sect2>
<title>Learning recursion in XQuery</title>
<para>XML is an inherently recursive data structure: trees contain sub-trees, so many
XQuery functions for transforming documents are best designed using recursion. One
good place to start learning recursion is the identity node filter functions in the
XQuery wikibook.</para>
</sect2>
<sect2>
<title>Effective use of your IDE</title>
<para>Most developers who do XQuery more than a few hours a day eventually end up using
a full commercial XQuery IDE, with oXygen being the best integrated with eXist.
Setting up oXygen is a bit tricky the first time since you need to load five jar
files into a "driver" for oXygen. Yet once this is done and the default XQuery
engine is set up to use eXist, there are many high-productivity features that are
enabled. Central to this is the XQuery auto-complete feature. As you type within
XQuery, all eXist functions and their parameters are shown in the IDE. For example
if you type "xmldb:" all the functions of the XMLDB module will automatically appear
in a drop-down list. As you continue to type or select a function the parameters and
types are also shown. This becomes a large time saver as you use more XQuery
functions.</para>
</sect2>
</sect1>
<sect1>
<title>Learning XQuery Resources</title>
<para>The following is an annotated list of resources that can help you learn XQuery.</para>
<bibliography>
<biblioentry>
<title>XQuery 1.0 W3C Specification</title>
<biblioid>http://www.w3.org/TR/xquery/</biblioid>
<bibliomisc>The official 1.0 specification. You should use XQuery 1.0 to keep your
XQuery programs portable.</bibliomisc>
</biblioentry>
<biblioentry>
<title>XQuery Wikibook</title>
<biblioid>http://en.wikibooks.org/wiki/XQuery</biblioid>
<bibliomisc>A collection of sample programs in XQuery using the eXist system. Note
that some examples are not complete and some may not be updated to use the
latest release of eXist.</bibliomisc>
</biblioentry>
<biblioentry>
<title>XQuery Wikibook</title>
<biblioid>http://en.wikibooks.org/wiki/XQuery</biblioid>
<bibliomisc>A collection of sample programs in XQuery using the eXist system. Note
that some examples are not complete and some may not be updated to use the
latest release of eXist.</bibliomisc>
</biblioentry>
<biblioentry>
<title>XQuery Wikibook Beginning_Examples</title>
<biblioid>http://en.wikibooks.org/wiki/XQuery#Beginning_Examples</biblioid>
<bibliomisc>Simple examples starting with basic sequences and FLOWR
statements</bibliomisc>
</biblioentry>
<biblioentry>
<title>XQuery Wikipedia Article</title>
<biblioid>http://en.wikipedia.org/wiki/XQuery</biblioid>
<bibliomisc>An excellent brief overview of what XQuery is and it main features. </bibliomisc>
</biblioentry>
<biblioentry>
<title>XQuery Wikibook - Beginning Examples</title>
<biblioid>http://en.wikibooks.org/wiki/XQuery</biblioid>
<bibliomisc>A collection of sample programs in XQuery using the eXist system. Note
that some examples are not complete and some may not be updated to use the
latest release of eXist.</bibliomisc>
</biblioentry>
<biblioentry>
<title>XQuery Book by Priscilla Walmsley</title>
<biblioid>http://www.datypic.com/books/xquery/</biblioid>
<bibliomisc>A precise and thorough coverage of all the features of the XQuery
language. An excellent and well-written reference book for all XQuery
developers. This book is frequently cited in other XQuery
tutorials.</bibliomisc>
</biblioentry>
<biblioentry>
<title>XQuery Tutorial at the commercial W3C schools site</title>
<biblioid>http://www.w3schools.com/xquery</biblioid>
<bibliomisc>Basic XQuery tutorial but not recommended for eXist specific items.
Discussion of XLink and XPointer should not be used.</bibliomisc>
</biblioentry>
</bibliography>
</sect1>
</article>