examples.xml 3.48 KB
Newer Older
Giuseppe Castagna's avatar
Giuseppe Castagna committed
1
<?xml version="1.0" encoding="UTF-8"?>
2
3
<examples>

4

Giuseppe Castagna's avatar
Giuseppe Castagna committed
5
<example code="qatt1" title="Attributes and elements">
Giuseppe Castagna's avatar
Giuseppe Castagna committed
6
Part 1
7
8
</example>

Giuseppe Castagna's avatar
Giuseppe Castagna committed
9
<example code="qatt2" title="Attributes and elements">
Giuseppe Castagna's avatar
Giuseppe Castagna committed
10
Part 2
11
12
</example>

Giuseppe Castagna's avatar
Giuseppe Castagna committed
13
<example code="qatt3" title="Attributes and elements">
Giuseppe Castagna's avatar
Giuseppe Castagna committed
14
Part 3
15
16
17
</example>


18
19
20
21
<example code="xml" title="XML elements">
XML elements.
</example>

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
<example  code="functions"  title="Functions">
Several syntaxes to define functions.
</example>

<example code="mutrec" title="Mutual recursion">
Mutual toplevel definition for types and functions.
</example>

<example code="sequence" title="Sequence literals">
How to write sequences.
</example>

<example code="seqtypes" title="Sequence types">
Types for sequences.
</example>

<example code="integers" title="The factorial function">
What about computing 10000! ?
</example>

<example code="sumtype" title="Sum types">
How to simulate ML sum types.
</example>

<example code="ovfun" title="Overloaded functions">
This examples demonstrates the use of overloaded functions.
</example>

<example code="note" title="Footnotes">
 This example shows how to bind an XML element with surrounding text.
</example>

<example code="biblio" title="Bibliography">
The good old XML bibliography example.
</example>

<example code="projection" title="Projection">
Syntactic sugar for projection.
</example>

62
63
64
65
<example code="xtransform" title="Tree transformations">
How to perform XSLT-like transformations.
</example>

66
67
68
<example code="reference" title="References">
Mutable values.
</example>
69

70
71
72
73
74
<example code="pm_compil" title="Compilation of pattern matching">
This example demonstrates the efficient compilation of pattern
matching.
</example>

Giuseppe Castagna's avatar
Giuseppe Castagna committed
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
<example code="q1" title="Q1">
Q1 Query: List books published by Addison-Wesley after 1991, including their year and title.
</example>

<example code="q2" title="Q2">
Q2 Query: Create a flat list of all the title-author pairs, with each pair enclosed in a \"result\" element.
</example>

<example code="q3" title="Q3">
Q3 Query: For each book in the bibliography, list the title and authors, grouped inside a \"result\" element.
</example>

<example code="q4" title="Q4">
Q4 Query: For each author in the bibliography, list the author`s name and the titles 
of all books by that author, grouped inside a \"result\" element.
</example>

<example code="q5" title="Q5">
Q5 Query: For each book found at both bstore1.example.com and bstore2.example.com, 
list the title of the book and its price from each source.
</example>

<example code="q6" title="Q6">
Q6 Query: For each book that has at least one author, list the title and first two authors, 
and an empty \"et-al\" element if the book has additional authors.
</example>

<example code="q8" title="Q8">
Q8 Query: Find books in which the name of some element ends with the string \"or\" 
and the same element contains the string \"Suciu\" somewhere in its content. 
For each such book, return the title and the qualifying element.
</example>

<example code="q9" title="Q9">
Q9 Query: In the document \"books.xml\", find all section or chapter titles that 
contain the word \"XML\", regardless of the level of nesting.
</example>

<example code="q11" title="Q11">
Q11 Query: For each book with an author, return the book with its title and authors. 
For each book with an editor, return a reference with the book title and the editor`s affiliation.
</example>

<example code="q12" title="Q12">
Q12 Query: Find pairs of books that have different titles but the same set of authors (possibly in a different order).
</example>

122

123
</examples>
124
125