0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the documentation of the Qt Toolkit.
|
|
8 |
**
|
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
10 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
15 |
**
|
|
16 |
** GNU Lesser General Public License Usage
|
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
18 |
** General Public License version 2.1 as published by the Free Software
|
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
20 |
** packaging of this file. Please review the following information to
|
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
23 |
**
|
|
24 |
** In addition, as a special exception, Nokia gives you certain additional
|
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
27 |
**
|
|
28 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
38 |
** $QT_END_LICENSE$
|
|
39 |
**
|
|
40 |
****************************************************************************/
|
|
41 |
|
|
42 |
|
|
43 |
void wrapInFunction()
|
|
44 |
{
|
|
45 |
|
|
46 |
//! [0]
|
|
47 |
#include <QtXmlPatterns>
|
|
48 |
//! [0]
|
|
49 |
|
|
50 |
|
|
51 |
//! [1]
|
|
52 |
QT += xmlpatterns
|
|
53 |
//! [1]
|
|
54 |
|
|
55 |
//! [2]
|
|
56 |
xmlpatterns myQuery.xq
|
|
57 |
//! [2]
|
|
58 |
|
|
59 |
//! [3]
|
|
60 |
declare namespace c = "http://cookbook/namespace";
|
|
61 |
doc('cookbook.xml')//c:recipe/c:title
|
|
62 |
//! [3]
|
|
63 |
|
|
64 |
//! [4]
|
|
65 |
declare default element namespace "http://cookbook/namespace";
|
|
66 |
doc('cookbook.xml')//recipe/title
|
|
67 |
//! [4]
|
|
68 |
|
|
69 |
//! [5]
|
|
70 |
<title xmlns="http://cookbook/namespace">Quick and Easy Mushroom Soup</title>
|
|
71 |
<title xmlns="http://cookbook/namespace">Cheese on Toast</title>
|
|
72 |
<title xmlns="http://cookbook/namespace">Hard-Boiled Eggs</title>
|
|
73 |
//! [5]
|
|
74 |
|
|
75 |
//! [6]
|
|
76 |
xmlpatterns file.xq
|
|
77 |
//! [6]
|
|
78 |
|
|
79 |
//! [7]
|
|
80 |
doc('cookbook.xml')//@xml:*
|
|
81 |
//! [7]
|
|
82 |
|
|
83 |
//! [8]
|
|
84 |
doc('cookbook.xml')//@*:name
|
|
85 |
//! [8]
|
|
86 |
|
|
87 |
//! [9]
|
|
88 |
declare default element namespace "http://cookbook/namespace";
|
|
89 |
doc('cookbook.xml')/cookbook/@*
|
|
90 |
//! [9]
|
|
91 |
|
|
92 |
//! [10]
|
|
93 |
declare default element namespace "http://cookbook/namespace";
|
|
94 |
doc("cookbook.xml")/cookbook/recipe[title = "Hard-Boiled Eggs"]
|
|
95 |
//! [10]
|
|
96 |
|
|
97 |
//! [11]
|
|
98 |
declare default element namespace "http://cookbook/namespace";
|
|
99 |
doc('cookbook.xml')//method[string-length(.) = 0]
|
|
100 |
//! [11]
|
|
101 |
|
|
102 |
//! [12]
|
|
103 |
declare default element namespace "http://cookbook/namespace";
|
|
104 |
doc('cookbook.xml')//method[string-length() = 0]
|
|
105 |
//! [12]
|
|
106 |
|
|
107 |
//! [13]
|
|
108 |
declare default element namespace "http://cookbook/namespace";
|
|
109 |
doc('cookbook.xml')/cookbook/recipe[2]
|
|
110 |
//! [13]
|
|
111 |
|
|
112 |
//! [14]
|
|
113 |
declare default element namespace "http://cookbook/namespace";
|
|
114 |
doc('cookbook.xml')/cookbook/recipe[position() = 2]
|
|
115 |
//! [14]
|
|
116 |
|
|
117 |
//! [15]
|
|
118 |
declare default element namespace "http://cookbook/namespace";
|
|
119 |
doc('cookbook.xml')/cookbook/recipe[position() > 1]
|
|
120 |
//! [15]
|
|
121 |
|
|
122 |
//! [16]
|
|
123 |
declare default element namespace "http://cookbook/namespace";
|
|
124 |
doc('cookbook.xml')/cookbook/recipe[last()]
|
|
125 |
//! [16]
|
|
126 |
|
|
127 |
//! [17]
|
|
128 |
declare default element namespace "http://cookbook/namespace";
|
|
129 |
doc('cookbook.xml')/cookbook/recipe[last() - 1]
|
|
130 |
//! [17]
|
|
131 |
|
|
132 |
//! [18]
|
|
133 |
doc('cookbook.xml')//recipe
|
|
134 |
//! [18]
|
|
135 |
|
|
136 |
//! [19]
|
|
137 |
doc('cookbook.xml')//recipe/title
|
|
138 |
//! [19]
|
|
139 |
|
|
140 |
//! [20]
|
|
141 |
<recipe/>
|
|
142 |
//! [20]
|
|
143 |
|
|
144 |
//! [21]
|
|
145 |
<html xmlns="http://www.w3.org/1999/xhtml/"
|
|
146 |
xml:id="{doc("other.html")/html/@xml:id}"/>
|
|
147 |
//! [21]
|
|
148 |
|
|
149 |
//! [22]
|
|
150 |
doc('cookbook.xml')/descendant-or-self::element(recipe)/child::element(title)
|
|
151 |
//! [22]
|
|
152 |
|
|
153 |
//! [23]
|
|
154 |
<cookbook>
|
|
155 |
//! [23]
|
|
156 |
|
|
157 |
//! [24]
|
|
158 |
<cookbook xmlns="http://cookbook/namespace">
|
|
159 |
//! [24]
|
|
160 |
|
|
161 |
//! [25]
|
|
162 |
for $i in doc("cookbook.xml")//@xml:*
|
|
163 |
return <p>{$i}</p>
|
|
164 |
//! [25]
|
|
165 |
|
|
166 |
//! [26]
|
|
167 |
for $i in doc("cookbook.xml")//@*:name
|
|
168 |
return <p>{$i}</p>
|
|
169 |
//! [26]
|
|
170 |
|
|
171 |
//! [27]
|
|
172 |
declare default element namespace "http://cookbook/namespace";
|
|
173 |
for $i in doc("cookbook.xml")/cookbook/@*
|
|
174 |
return <p>{$i}</p>
|
|
175 |
//! [27]
|
|
176 |
|
|
177 |
//! [28]
|
|
178 |
<p xml:id="MushroomSoup"/>
|
|
179 |
<p xml:id="CheeseOnToast"/>
|
|
180 |
<p xml:id="HardBoiledEggs"/>
|
|
181 |
//! [28]
|
|
182 |
|
|
183 |
//! [29]
|
|
184 |
<p name="Fresh mushrooms"/>
|
|
185 |
<p name="Garlic"/>
|
|
186 |
<p name="Olive oil"/>
|
|
187 |
<p name="Milk"/>
|
|
188 |
<p name="Water"/>
|
|
189 |
<p name="Cream"/>
|
|
190 |
<p name="Vegetable soup cube"/>
|
|
191 |
<p name="Ground black pepper"/>
|
|
192 |
<p name="Dried parsley"/>
|
|
193 |
<p name="Bread"/>
|
|
194 |
<p name="Cheese"/>
|
|
195 |
<p name="Eggs"/>
|
|
196 |
//! [29]
|
|
197 |
|
|
198 |
//! [30]
|
|
199 |
<p xmlns="http://cookbook/namespace" count="3"/>
|
|
200 |
//! [30]
|
|
201 |
|
|
202 |
//! [31]
|
|
203 |
<method xmlns="http://cookbook/namespace"/>
|
|
204 |
//! [31]
|
|
205 |
|
|
206 |
//! [32]
|
|
207 |
declare default element namespace "http://cookbook/namespace";
|
|
208 |
doc('cookbook.xml')//recipe[string-length(method) = 0]
|
|
209 |
//! [32]
|
|
210 |
|
|
211 |
//! [33]
|
|
212 |
<recipe xmlns="http://cookbook/namespace" xml:id="HardBoiledEggs">
|
|
213 |
<title>Hard-Boiled Eggs</title>
|
|
214 |
<ingredient name="Eggs" quantity="3" unit="eggs"/>
|
|
215 |
<time quantity="3" unit="minutes"/>
|
|
216 |
<method/>
|
|
217 |
</recipe>
|
|
218 |
//! [33]
|
|
219 |
|
|
220 |
//! [34]
|
|
221 |
declare default element namespace "http://cookbook/namespace";
|
|
222 |
doc('cookbook.xml')/cookbook/recipe[method[empty(step)]]
|
|
223 |
//! [34]
|
|
224 |
|
|
225 |
//! [35]
|
|
226 |
declare default element namespace "http://cookbook/namespace";
|
|
227 |
doc('cookbook.xml')/cookbook/recipe[not(normalize-space(method))]
|
|
228 |
//! [35]
|
|
229 |
|
|
230 |
//! [36]
|
|
231 |
<e>{sum((1, 2, 3))}</e>
|
|
232 |
//! [36]
|
|
233 |
|
|
234 |
//! [37]
|
|
235 |
<e>6</e>
|
|
236 |
//! [37]
|
|
237 |
|
|
238 |
//![38]
|
|
239 |
declare variable $insertion := "example";
|
|
240 |
<p class="important {$insertion} obsolete"/>
|
|
241 |
//![38]
|
|
242 |
|
|
243 |
//! [39]
|
|
244 |
<p class="important example obsolete"/>
|
|
245 |
//! [39]
|
|
246 |
|
|
247 |
//! [40]
|
|
248 |
declare default element namespace "http://cookbook/namespace";
|
|
249 |
let $docURI := 'cookbook.xml'
|
|
250 |
return if(doc-available($docURI))
|
|
251 |
then doc($docURI)//recipe/<oppskrift>{./node()}</oppskrift>
|
|
252 |
else <oppskrift>Failed to load {$docURI}</oppskrift>
|
|
253 |
//! [40]
|
|
254 |
|
|
255 |
//! [41]
|
|
256 |
<span>1</span>
|
|
257 |
<span>3</span>
|
|
258 |
<span>5</span>
|
|
259 |
<span>7</span>
|
|
260 |
<span>9</span>
|
|
261 |
<span>b</span>
|
|
262 |
<span>d</span>
|
|
263 |
<span>f</span>
|
|
264 |
//! [41]
|
|
265 |
|
|
266 |
//! [42]
|
|
267 |
<span>1</span>
|
|
268 |
//! [42]
|
|
269 |
|
|
270 |
//! [43]
|
|
271 |
let $doc := doc('doc.txt')
|
|
272 |
return $doc/doc/p[1]/span[1]
|
|
273 |
//! [43]
|
|
274 |
|
|
275 |
//! [44]
|
|
276 |
for $a in doc('doc.txt')/doc/p/span[1]
|
|
277 |
return $a
|
|
278 |
//! [44]
|
|
279 |
|
|
280 |
//! [45]
|
|
281 |
doc('doc.txt')/doc/p/span[1]
|
|
282 |
//! [45]
|
|
283 |
|
|
284 |
//! [46]
|
|
285 |
doc('doc.txt')//p/<p>{span/node()}</p>
|
|
286 |
//! [46]
|
|
287 |
|
|
288 |
//! [47]
|
|
289 |
<p>78</p>
|
|
290 |
<p>9a</p>
|
|
291 |
<p>12</p>
|
|
292 |
<p>bc</p>
|
|
293 |
<p>de</p>
|
|
294 |
<p>34</p>
|
|
295 |
<p>56</p>
|
|
296 |
<p>f0</p>
|
|
297 |
//! [47]
|
|
298 |
|
|
299 |
//! [48]
|
|
300 |
for $a in doc('doc.txt')//p
|
|
301 |
return <p>{$a/span/node()}</p>
|
|
302 |
//! [48]
|
|
303 |
|
|
304 |
//! [49]
|
|
305 |
<p>12</p>
|
|
306 |
<p>34</p>
|
|
307 |
<p>56</p>
|
|
308 |
<p>78</p>
|
|
309 |
<p>9a</p>
|
|
310 |
<p>bc</p>
|
|
311 |
<p>de</p>
|
|
312 |
<p>f0</p>
|
|
313 |
//! [49]
|
|
314 |
|
|
315 |
}
|
|
316 |
|