| 1 | /**************************************************************************** | 
|---|
| 2 | ** | 
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). | 
|---|
| 4 | ** Contact: Qt Software Information (qt-info@nokia.com) | 
|---|
| 5 | ** | 
|---|
| 6 | ** This file is part of the documentation of the Qt Toolkit. | 
|---|
| 7 | ** | 
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | 
|---|
| 9 | ** Commercial Usage | 
|---|
| 10 | ** Licensees holding valid Qt Commercial licenses may use this file in | 
|---|
| 11 | ** accordance with the Qt Commercial License Agreement provided with the | 
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in | 
|---|
| 13 | ** a written agreement between you and Nokia. | 
|---|
| 14 | ** | 
|---|
| 15 | ** GNU Lesser General Public License Usage | 
|---|
| 16 | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
|---|
| 17 | ** General Public License version 2.1 as published by the Free Software | 
|---|
| 18 | ** Foundation and appearing in the file LICENSE.LGPL included in the | 
|---|
| 19 | ** packaging of this file.  Please review the following information to | 
|---|
| 20 | ** ensure the GNU Lesser General Public License version 2.1 requirements | 
|---|
| 21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | 
|---|
| 22 | ** | 
|---|
| 23 | ** In addition, as a special exception, Nokia gives you certain | 
|---|
| 24 | ** additional rights. These rights are described in the Nokia Qt LGPL | 
|---|
| 25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this | 
|---|
| 26 | ** package. | 
|---|
| 27 | ** | 
|---|
| 28 | ** GNU General Public License Usage | 
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU | 
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software | 
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the | 
|---|
| 32 | ** packaging of this file.  Please review the following information to | 
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be | 
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html. | 
|---|
| 35 | ** | 
|---|
| 36 | ** If you are unsure which license is appropriate for your use, please | 
|---|
| 37 | ** contact the sales department at qt-sales@nokia.com. | 
|---|
| 38 | ** $QT_END_LICENSE$ | 
|---|
| 39 | ** | 
|---|
| 40 | ****************************************************************************/ | 
|---|
| 41 |  | 
|---|
| 42 | /*! | 
|---|
| 43 | \module QtXmlPatterns | 
|---|
| 44 | \title QtXmlPatterns Module | 
|---|
| 45 | \since 4.4 | 
|---|
| 46 | \contentspage Qt's Modules | 
|---|
| 47 | \previouspage QtXml | 
|---|
| 48 | \nextpage Phonon Module | 
|---|
| 49 | \ingroup modules | 
|---|
| 50 | \ingroup scripting | 
|---|
| 51 |  | 
|---|
| 52 | \keyword Patternist | 
|---|
| 53 |  | 
|---|
| 54 | \brief An overview of Qt's support for using XQuery and XPath in | 
|---|
| 55 | Qt programs. | 
|---|
| 56 |  | 
|---|
| 57 | \tableofcontents | 
|---|
| 58 |  | 
|---|
| 59 | \section1 Introduction | 
|---|
| 60 |  | 
|---|
| 61 | XQuery is a language for traversing XML documents to select and | 
|---|
| 62 | aggregate items of interest and to transform them for output as | 
|---|
| 63 | XML or some other format. XPath is the \e{element selection} part | 
|---|
| 64 | of XQuery. | 
|---|
| 65 |  | 
|---|
| 66 | The QtXmlPatterns module supports using | 
|---|
| 67 | \l{http://www.w3.org/TR/xquery} {XQuery 1.0} and | 
|---|
| 68 | \l{http://www.w3.org/TR/xpath20} {XPath 2.0} in Qt applications, | 
|---|
| 69 | for querying XML data \e{and} for querying | 
|---|
| 70 | \l{QAbstractXmlNodeModel} {non-XML data that can be modeled to | 
|---|
| 71 | look like XML}. The QtXmlPatterns module is included in the \l{Qt | 
|---|
| 72 | Full Framework Edition}, and the \l{Open Source Versions of Qt}. | 
|---|
| 73 | Readers who are not familiar with the XQuery/XPath language can read | 
|---|
| 74 | \l {A Short Path to XQuery} for a brief introduction. | 
|---|
| 75 |  | 
|---|
| 76 | \section1 Advantages of using QtXmlPatterns and XQuery | 
|---|
| 77 |  | 
|---|
| 78 | The XQuery/XPath language simplifies data searching and | 
|---|
| 79 | transformation tasks by eliminating the need for doing a lot of | 
|---|
| 80 | C++ or Java procedural programming for each new query task. Here | 
|---|
| 81 | is an XQuery that constructs a bibliography of the contents of a | 
|---|
| 82 | library: | 
|---|
| 83 |  | 
|---|
| 84 | \target qtxmlpatterns_example_query | 
|---|
| 85 | \quotefile snippets/patternist/introductionExample.xq | 
|---|
| 86 |  | 
|---|
| 87 | First, the query opens a \c{<bibliography>} element in the | 
|---|
| 88 | output. The | 
|---|
| 89 | \l{xquery-introduction.html#using-path-expressions-to-match-select-items} | 
|---|
| 90 | {embedded path expression} then loads the XML document describing | 
|---|
| 91 | the contents of the library (\c{library.xml}) and begins the | 
|---|
| 92 | search. For each \c{<book>} element it finds, where the publisher | 
|---|
| 93 | was Addison-Wesley and the publication year was after 1991, it | 
|---|
| 94 | creates a new \c{<book>} element in the output as a child of the | 
|---|
| 95 | open \c{<bibliography>} element. Each new \c{<book>} element gets | 
|---|
| 96 | the book's title as its contents and the book's publication year | 
|---|
| 97 | as an attribute. Finally, the \c{<bibliography>} element is | 
|---|
| 98 | closed. | 
|---|
| 99 |  | 
|---|
| 100 | The advantages of using QtXmlPatterns and XQuery in your Qt | 
|---|
| 101 | programs are summarized as follows: | 
|---|
| 102 |  | 
|---|
| 103 | \list | 
|---|
| 104 |  | 
|---|
| 105 | \o \bold{Ease of development}: All the C++ programming required to | 
|---|
| 106 | perform data query tasks can be replaced by a simple XQuery | 
|---|
| 107 | like the example above. | 
|---|
| 108 |  | 
|---|
| 109 | \o \bold{Comprehensive functionality}: The | 
|---|
| 110 | \l{http://www.w3.org/TR/xquery/#id-expressions} {expression | 
|---|
| 111 | syntax} and rich set of | 
|---|
| 112 | \l{http://www.w3.org/TR/xpath-functions} {functions and | 
|---|
| 113 | operators} provided by XQuery are sufficient for performing any | 
|---|
| 114 | data searching, selecting, and sorting tasks. | 
|---|
| 115 |  | 
|---|
| 116 | \o \bold{Conformance to standards}: Conformance to all applicable | 
|---|
| 117 | XML and XQuery standards ensures that QtXmlPatterns can always | 
|---|
| 118 | process XML documents generated by other conformant | 
|---|
| 119 | applications, and that XML documents created with QtXmlPatterns | 
|---|
| 120 | can be processed by other conformant applications. | 
|---|
| 121 |  | 
|---|
| 122 | \o \bold{Maximal flexibility} The QtXmlPatterns module can be used | 
|---|
| 123 | to query XML data \e{and} non-XML data that can be | 
|---|
| 124 | \l{QAbstractXmlNodeModel} {modeled to look like XML}. | 
|---|
| 125 |  | 
|---|
| 126 | \endlist | 
|---|
| 127 |  | 
|---|
| 128 | \section1 Using the QtXmlPatterns module | 
|---|
| 129 |  | 
|---|
| 130 | There are two ways QtXmlPatterns can be used to evaluate queries. | 
|---|
| 131 | You can run the query engine in your Qt application using the | 
|---|
| 132 | QtXmlPatterns C++ API, or you can run the query engine from the | 
|---|
| 133 | command line using Qt's \c{xmlpatterns} command line utility. | 
|---|
| 134 |  | 
|---|
| 135 | \section2 Running the query engine from your Qt application | 
|---|
| 136 |  | 
|---|
| 137 | To access the QtXmlPatterns C++ API from your Qt application, | 
|---|
| 138 | include the QtXmlPatterns classes at compile time: | 
|---|
| 139 |  | 
|---|
| 140 | \snippet doc/src/snippets/code/doc_src_qtxmlpatterns.qdoc 0 | 
|---|
| 141 |  | 
|---|
| 142 | Link the compiled application with the QtXmlPatterns module by | 
|---|
| 143 | adding the following line to the | 
|---|
| 144 | \l{qmake-project-files.html#declaring-qt-libraries} {QT line} in | 
|---|
| 145 | your qmake \c{.pro} file: | 
|---|
| 146 |  | 
|---|
| 147 | \snippet doc/src/snippets/code/doc_src_qtxmlpatterns.qdoc 1 | 
|---|
| 148 |  | 
|---|
| 149 | If we save the example XQuery shown above in a text file (e.g. | 
|---|
| 150 | \c{myquery.xq}), we can run it from a Qt application using a | 
|---|
| 151 | standard QtXmlPatterns code sequence: | 
|---|
| 152 |  | 
|---|
| 153 | \snippet doc/src/snippets/code/src_xmlpatterns_api_qxmlquery.cpp 3 | 
|---|
| 154 |  | 
|---|
| 155 | First construct a QFile for the text file containing the XQuery | 
|---|
| 156 | (\c{myquery.xq}). Then create an instance of QXmlQuery and call | 
|---|
| 157 | its \l{QXmlQuery::}{setQuery()} function to load and parse the | 
|---|
| 158 | XQuery file. Then create an \l{QXmlSerializer} {XML serializer} to | 
|---|
| 159 | output the query's result set as unformatted XML. Finally, call | 
|---|
| 160 | the \l{QXmlQuery::}{evaluateTo()} function to evaluate the query | 
|---|
| 161 | and serialize the results as XML. | 
|---|
| 162 |  | 
|---|
| 163 | \note If you compile Qt yourself, the QtXmlPatterns module will | 
|---|
| 164 | \e{not} be built if exceptions are disabled, or if you compile Qt | 
|---|
| 165 | with a compiler that doesn't support member templates, e.g., MSVC | 
|---|
| 166 | 6. | 
|---|
| 167 |  | 
|---|
| 168 | See the QXmlQuery documentation for more information about the | 
|---|
| 169 | QtXmlPatterns C++ API. | 
|---|
| 170 |  | 
|---|
| 171 | \section2 Running the query engine from the command line utility | 
|---|
| 172 |  | 
|---|
| 173 | \e xmlpatterns is a command line utility for running XQueries.  It | 
|---|
| 174 | expects the name of a file containing the XQuery text. | 
|---|
| 175 |  | 
|---|
| 176 | \snippet doc/src/snippets/code/doc_src_qtxmlpatterns.qdoc 2 | 
|---|
| 177 |  | 
|---|
| 178 | The XQuery in \c{myQuery.xq} will be evaluated and its output | 
|---|
| 179 | written to \c stdout. Pass the \c -help switch to get the list of | 
|---|
| 180 | input flags and their meanings. | 
|---|
| 181 |  | 
|---|
| 182 | xmlpatterns can be used in scripting. However, the descriptions | 
|---|
| 183 | and messages it outputs were not meant to be parsed and may be | 
|---|
| 184 | changed in future releases of Qt. | 
|---|
| 185 |  | 
|---|
| 186 | \target QtXDM | 
|---|
| 187 | \section1 The XQuery Data Model | 
|---|
| 188 |  | 
|---|
| 189 | XQuery represents data items as \e{atomic values} or \e{nodes}. An | 
|---|
| 190 | atomic value is a value in the domain of one of the | 
|---|
| 191 | \l{http://www.w3.org/TR/xmlschema-2/#built-in-datatypes} {built-in | 
|---|
| 192 | datatypes} defined in \l{http://www.w3.org/TR/xmlschema-2} {Part | 
|---|
| 193 | 2} of the W3C XML Schema. A node is normally an XML element or | 
|---|
| 194 | attribute, but when non-XML data is \l{QAbstractXmlNodeModel} | 
|---|
| 195 | {modeled to look like XML}, a node can also represent a non-XML | 
|---|
| 196 | data items. | 
|---|
| 197 |  | 
|---|
| 198 | When you run an XQuery using the C++ API in a Qt application, you | 
|---|
| 199 | will often want to bind program variables to $variables in the | 
|---|
| 200 | XQuery. After the query is evaluated, you will want to interpret | 
|---|
| 201 | the sequence of data items in the result set. | 
|---|
| 202 |  | 
|---|
| 203 | \section2 Binding program variables to XQuery variables | 
|---|
| 204 |  | 
|---|
| 205 | When you want to run a parameterized XQuery from your Qt | 
|---|
| 206 | application, you will need to \l{QXmlQuery::bindVariable()} {bind | 
|---|
| 207 | variables} in your program to $name variables in your XQuery. | 
|---|
| 208 |  | 
|---|
| 209 | Suppose you want to parameterize the bibliography XQuery in the | 
|---|
| 210 | example above. You could define variables for the catalog that | 
|---|
| 211 | contains the library (\c{$file}), the publisher name | 
|---|
| 212 | (\c{$publisher}), and the year of publication (\c{$year}): | 
|---|
| 213 |  | 
|---|
| 214 | \target qtxmlpatterns_example_query2 | 
|---|
| 215 | \quotefile snippets/patternist/introExample2.xq | 
|---|
| 216 |  | 
|---|
| 217 | Modify the QtXmlPatterns code to use one of the \l{QXmlQuery::} | 
|---|
| 218 | {bindVariable()} functions to bind a program variable to each | 
|---|
| 219 | XQuery $variable: | 
|---|
| 220 |  | 
|---|
| 221 | \snippet doc/src/snippets/code/src_xmlpatterns_api_qxmlquery.cpp 4 | 
|---|
| 222 |  | 
|---|
| 223 | Each program variable is passed to QtXmlPatterns as a QVariant of | 
|---|
| 224 | the type of the C++ variable or constant from which it is | 
|---|
| 225 | constructed. Note that QtXmlPatterns assumes that the type of the | 
|---|
| 226 | QVariant in the bindVariable() call is the correct type, so the | 
|---|
| 227 | $variable it is bound to must be used in the XQuery accordingly. | 
|---|
| 228 | The following table shows how QVariant types are mapped to XQuery | 
|---|
| 229 | $variable types: | 
|---|
| 230 |  | 
|---|
| 231 | \table | 
|---|
| 232 |  | 
|---|
| 233 | \header | 
|---|
| 234 | \o QVariant type | 
|---|
| 235 | \o XQuery $variable type | 
|---|
| 236 |  | 
|---|
| 237 | \row | 
|---|
| 238 | \o QVariant::LongLong | 
|---|
| 239 | \o \c xs:integer | 
|---|
| 240 |  | 
|---|
| 241 | \row | 
|---|
| 242 | \o QVariant::Int | 
|---|
| 243 | \o \c xs:integer | 
|---|
| 244 |  | 
|---|
| 245 | \row | 
|---|
| 246 | \o QVariant::UInt | 
|---|
| 247 | \o \c xs:nonNegativeInteger | 
|---|
| 248 |  | 
|---|
| 249 | \row | 
|---|
| 250 | \o QVariant::ULongLong | 
|---|
| 251 | \o \c xs:unsignedLong | 
|---|
| 252 |  | 
|---|
| 253 | \row | 
|---|
| 254 | \o QVariant::String | 
|---|
| 255 | \o \c xs:string | 
|---|
| 256 |  | 
|---|
| 257 | \row | 
|---|
| 258 | \o QVariant::Double | 
|---|
| 259 | \o \c xs:double | 
|---|
| 260 |  | 
|---|
| 261 | \row | 
|---|
| 262 | \o QVariant::Bool | 
|---|
| 263 | \o \c xs:boolean | 
|---|
| 264 |  | 
|---|
| 265 | \row | 
|---|
| 266 | \o QVariant::Double | 
|---|
| 267 | \o \c xs:decimal | 
|---|
| 268 |  | 
|---|
| 269 | \row | 
|---|
| 270 | \o QVariant::ByteArray | 
|---|
| 271 | \o \c xs:base64Binary | 
|---|
| 272 |  | 
|---|
| 273 | \row | 
|---|
| 274 | \o QVariant::StringList | 
|---|
| 275 | \o \c xs:string* | 
|---|
| 276 |  | 
|---|
| 277 | \row | 
|---|
| 278 | \o QVariant::Url | 
|---|
| 279 | \o \c xs:string | 
|---|
| 280 |  | 
|---|
| 281 | \row | 
|---|
| 282 | \o QVariant::Date | 
|---|
| 283 | \o \c xs:date. | 
|---|
| 284 |  | 
|---|
| 285 | \row | 
|---|
| 286 | \o QVariant::DateTime | 
|---|
| 287 | \o \c xs:dateTime | 
|---|
| 288 |  | 
|---|
| 289 | \row | 
|---|
| 290 | \o QVariant::Time. | 
|---|
| 291 | \o \c xs:time. (see \l{Binding To Time}{Binding To | 
|---|
| 292 | QVariant::Time} below) | 
|---|
| 293 |  | 
|---|
| 294 | \row | 
|---|
| 295 | \o QVariantList | 
|---|
| 296 | \o (see \l{Binding To QVariantList}{Binding To QVariantList} | 
|---|
| 297 | below) | 
|---|
| 298 |  | 
|---|
| 299 | \endtable | 
|---|
| 300 |  | 
|---|
| 301 | A type not shown in the table is not supported and will cause | 
|---|
| 302 | undefined XQuery behavior or a $variable binding error, depending | 
|---|
| 303 | on the context in the XQuery where the variable is used. | 
|---|
| 304 |  | 
|---|
| 305 | \target Binding To Time | 
|---|
| 306 | \section3 Binding To QVariant::Time | 
|---|
| 307 |  | 
|---|
| 308 | Because the instance of QTime used in QVariant::Time does not | 
|---|
| 309 | include a zone offset, an instance of QVariant::Time should not be | 
|---|
| 310 | bound to an XQuery variable of type \c xs:time, unless the QTime is | 
|---|
| 311 | UTC. When binding a non-UTC QTime to an XQuery variable, it should | 
|---|
| 312 | first be passed as a string, or converted to a QDateTime with an arbitrary | 
|---|
| 313 | date, and then bound to an XQuery variable of type \c xs:dateTime. | 
|---|
| 314 |  | 
|---|
| 315 | \target Binding To QVariantList | 
|---|
| 316 | \section3 Binding To QVariantList | 
|---|
| 317 |  | 
|---|
| 318 | A QVariantList can be bound to an XQuery $variable. All the | 
|---|
| 319 | \l{QVariant}s in the list must be of the same atomic type, and the | 
|---|
| 320 | $variable the variant list is bound to must be of that same atomic | 
|---|
| 321 | type. If the QVariants in the list are not all of the same atomic | 
|---|
| 322 | type, the XQuery behavior is undefined. | 
|---|
| 323 |  | 
|---|
| 324 | \section2 Interpreting XQuery results | 
|---|
| 325 |  | 
|---|
| 326 | When the results of an XQuery are returned in a sequence of \l | 
|---|
| 327 | {QXmlResultItems} {result items}, atomic values in the sequence | 
|---|
| 328 | are treated as instances of QVariant. Suppose that instead of | 
|---|
| 329 | serializing the results of the XQuery as XML, we process the | 
|---|
| 330 | results programatically. Modify the standard QtXmlPatterns code | 
|---|
| 331 | sequence to call the overload of QXmlQuery::evaluateTo() that | 
|---|
| 332 | populates a sequence of \l {QXmlResultItems} {result items} with | 
|---|
| 333 | the XQuery results: | 
|---|
| 334 |  | 
|---|
| 335 | \snippet doc/src/snippets/code/src_xmlpatterns_api_qxmlquery.cpp 5 | 
|---|
| 336 |  | 
|---|
| 337 | Iterate through the \l {QXmlResultItems} {result items} and test | 
|---|
| 338 | each QXmlItem to see if it is an atomic value or a node. If it is | 
|---|
| 339 | an atomic value, convert it to a QVariant with \l {QXmlItem::} | 
|---|
| 340 | {toAtomicValue()} and switch on its \l {QVariant::type()} {variant | 
|---|
| 341 | type} to handle all the atomic values your XQuery might return. | 
|---|
| 342 | The following table shows the QVariant type to expect for each | 
|---|
| 343 | atomic value type (or QXmlName): | 
|---|
| 344 |  | 
|---|
| 345 | \table | 
|---|
| 346 |  | 
|---|
| 347 | \header | 
|---|
| 348 | \o XQuery result item type | 
|---|
| 349 | \o QVariant type returned | 
|---|
| 350 |  | 
|---|
| 351 | \row | 
|---|
| 352 | \o \c xs:QName | 
|---|
| 353 | \o QXmlName (see \l{Handling QXmlNames}{Handling QXmlNames} | 
|---|
| 354 | below) | 
|---|
| 355 |  | 
|---|
| 356 | \row | 
|---|
| 357 | \o \c xs:integer | 
|---|
| 358 | \o QVariant::LongLong | 
|---|
| 359 |  | 
|---|
| 360 | \row | 
|---|
| 361 | \o \c xs:string | 
|---|
| 362 | \o QVariant::String | 
|---|
| 363 |  | 
|---|
| 364 | \row | 
|---|
| 365 | \o \c xs:string* | 
|---|
| 366 | \o QVariant::StringList | 
|---|
| 367 |  | 
|---|
| 368 | \row | 
|---|
| 369 | \o \c xs:double | 
|---|
| 370 | \o QVariant::Double | 
|---|
| 371 |  | 
|---|
| 372 | \row | 
|---|
| 373 | \o \c xs:float | 
|---|
| 374 | \o QVariant::Double | 
|---|
| 375 |  | 
|---|
| 376 | \row | 
|---|
| 377 | \o \c xs:boolean | 
|---|
| 378 | \o QVariant::Bool | 
|---|
| 379 |  | 
|---|
| 380 | \row | 
|---|
| 381 | \o \c xs:decimal | 
|---|
| 382 | \o QVariant::Double | 
|---|
| 383 |  | 
|---|
| 384 | \row | 
|---|
| 385 | \o \c xs:hexBinary | 
|---|
| 386 | \o QVariant::ByteArray | 
|---|
| 387 |  | 
|---|
| 388 | \row | 
|---|
| 389 | \o \c xs:base64Binary | 
|---|
| 390 | \o QVariant::ByteArray | 
|---|
| 391 |  | 
|---|
| 392 | \row | 
|---|
| 393 | \o \c xs:gYear | 
|---|
| 394 | \o QVariant::DateTime | 
|---|
| 395 |  | 
|---|
| 396 | \row | 
|---|
| 397 | \o \c xs:gYearMonth | 
|---|
| 398 | \o QVariant::DateTime | 
|---|
| 399 |  | 
|---|
| 400 | \row | 
|---|
| 401 | \o \c xs:gMonthDay | 
|---|
| 402 | \o QVariant::DateTime | 
|---|
| 403 |  | 
|---|
| 404 | \row | 
|---|
| 405 | \o \c xs:gDay | 
|---|
| 406 | \o QVariant::DateTime | 
|---|
| 407 |  | 
|---|
| 408 | \row | 
|---|
| 409 | \o \c xs:gMonth | 
|---|
| 410 | \o QVariant::DateTime | 
|---|
| 411 |  | 
|---|
| 412 | \row | 
|---|
| 413 | \o \c xs:anyURI | 
|---|
| 414 | \o QVariant::Url | 
|---|
| 415 |  | 
|---|
| 416 | \row | 
|---|
| 417 | \o \c xs:untypedAtomic | 
|---|
| 418 | \o QVariant::String | 
|---|
| 419 |  | 
|---|
| 420 | \row | 
|---|
| 421 | \o \c xs:ENTITY | 
|---|
| 422 | \o QVariant::String | 
|---|
| 423 |  | 
|---|
| 424 | \row | 
|---|
| 425 | \o \c xs:date | 
|---|
| 426 | \o QVariant::DateTime | 
|---|
| 427 |  | 
|---|
| 428 | \row | 
|---|
| 429 | \o \c xs:dateTime | 
|---|
| 430 | \o QVariant::DateTime | 
|---|
| 431 |  | 
|---|
| 432 | \row | 
|---|
| 433 | \o \c xs:time | 
|---|
| 434 | \o (see \l{xstime-not-mapped}{No mapping for xs:time} below) | 
|---|
| 435 |  | 
|---|
| 436 | \endtable | 
|---|
| 437 |  | 
|---|
| 438 | \target Handling QXmlNames | 
|---|
| 439 | \section3 Handling QXmlNames | 
|---|
| 440 |  | 
|---|
| 441 | If your XQuery can return atomic value items of type \c{xs:QName}, | 
|---|
| 442 | they will appear in your QXmlResultItems as instances of QXmlName. | 
|---|
| 443 | Since the QVariant class does not support the QXmlName class | 
|---|
| 444 | directly, extracting them from QXmlResultItems requires a bit of | 
|---|
| 445 | slight-of-hand using the \l{QMetaType} {Qt metatype system}. We | 
|---|
| 446 | must modify our example to use a couple of template functions, a | 
|---|
| 447 | friend of QMetaType (qMetaTypeId<T>()) and a friend of QVariant | 
|---|
| 448 | (qVariantValue<T>()): | 
|---|
| 449 |  | 
|---|
| 450 | \snippet doc/src/snippets/code/src_xmlpatterns_api_qxmlquery.cpp 6 | 
|---|
| 451 |  | 
|---|
| 452 | To access the strings in a QXmlName returned by an | 
|---|
| 453 | \l{QXmlQuery::evaluateTo()} {XQuery evaluation}, the QXmlName must | 
|---|
| 454 | be accessed with the \l{QXmlNamePool} {name pool} from the | 
|---|
| 455 | instance of QXmlQuery that was used for the evaluation. | 
|---|
| 456 |  | 
|---|
| 457 | \target xstime-not-mapped | 
|---|
| 458 | \section3 No mapping for xs:time | 
|---|
| 459 |  | 
|---|
| 460 | An instance of \c xs:time can't be represented correctly as an | 
|---|
| 461 | instance of QVariant::Time, unless the \c xs:time is a UTC time. | 
|---|
| 462 | This is because xs:time has a zone offset (0 for UTC) in addition | 
|---|
| 463 | to the time value, which the QTime in QVariant::Time does not | 
|---|
| 464 | have. This means that if an XQuery tries to return an atomic value | 
|---|
| 465 | of type \c xs:time, an invalid QVariant will be returned. A query | 
|---|
| 466 | can return an atomic value of type xs:time by either converting it | 
|---|
| 467 | to an \c xs:dateTime with an arbitrary date, or to an \c xs:string. | 
|---|
| 468 |  | 
|---|
| 469 | \section1 Using XQuery with Non-XML Data | 
|---|
| 470 |  | 
|---|
| 471 | Although the XQuery language was designed for querying XML, with | 
|---|
| 472 | QtXmlPatterns one can use XQuery for querying any data that can | 
|---|
| 473 | be modeled to look like XML. Non-XML data is modeled to look like | 
|---|
| 474 | XML by loading it into a custom subclass of QAbstractXmlNodeModel, | 
|---|
| 475 | where it is then presented to the QtXmlPatterns XQuery engine via | 
|---|
| 476 | the same API the XQuery engine uses for querying XML. | 
|---|
| 477 |  | 
|---|
| 478 | When QtXmlPatterns loads and queries XML files and produces XML | 
|---|
| 479 | output, it can always load the XML data into its default XML node | 
|---|
| 480 | model, where it can be traversed efficiently. The XQuery below | 
|---|
| 481 | traverses the product orders found in the XML file \e myOrders.xml | 
|---|
| 482 | to find all the skin care product orders and output them ordered | 
|---|
| 483 | by shipping date. | 
|---|
| 484 |  | 
|---|
| 485 | \quotefile snippets/patternist/introAcneRemover.xq | 
|---|
| 486 |  | 
|---|
| 487 | QtXmlPatterns can be used out of the box to perform this | 
|---|
| 488 | query, provided \e myOrders.xml actually contains well-formed XML. It | 
|---|
| 489 | can be loaded directly into the default XML node model and | 
|---|
| 490 | traversed. But suppose we want QtXmlPatterns to perform queries on | 
|---|
| 491 | the hierarchical structure of the local file system. The default | 
|---|
| 492 | XML node model in QtXmlPatterns is not suitable for navigating the | 
|---|
| 493 | file system, because there is no XML file to load that contains a | 
|---|
| 494 | description of it. Such an XML file, if it existed, might look | 
|---|
| 495 | something like this: | 
|---|
| 496 |  | 
|---|
| 497 | \quotefile snippets/patternist/introFileHierarchy.xml | 
|---|
| 498 |  | 
|---|
| 499 | The \l{File System Example}{File System Example} does exactly this. | 
|---|
| 500 |  | 
|---|
| 501 | There is no such file to load into the default XML node model, but | 
|---|
| 502 | one can write a subclass of QAbstractXmlNodeModel to represent the | 
|---|
| 503 | file system. This custom XML node model, once populated with all | 
|---|
| 504 | the directory and file descriptors obtained directly from the | 
|---|
| 505 | system, presents the complete file system hierarchy to the query | 
|---|
| 506 | engine via the same API used by the default XML node model to | 
|---|
| 507 | present the contents of an XML file. In other words, once the | 
|---|
| 508 | custom XML node model is populated, it presents the file system to | 
|---|
| 509 | the query engine as if a description of it had been loaded into | 
|---|
| 510 | the default XML node model from an XML file like the one shown | 
|---|
| 511 | above. | 
|---|
| 512 |  | 
|---|
| 513 | Now we can write an XQuery to find all the XML files and parse | 
|---|
| 514 | them to find the ones that don't contain well-formed XML. | 
|---|
| 515 |  | 
|---|
| 516 | \quotefromfile snippets/patternist/introNavigateFS.xq | 
|---|
| 517 | \skipto <html> | 
|---|
| 518 | \printuntil | 
|---|
| 519 |  | 
|---|
| 520 | Without QtXmlPatterns, there is no simple way to solve this kind | 
|---|
| 521 | of problem. You might do it by writing a C++ program to traverse | 
|---|
| 522 | the file system, sniff out all the XML files, and submit each one | 
|---|
| 523 | to an XML parser to test that it contains valid XML. The C++ code | 
|---|
| 524 | required to write that program will probably be more complex than | 
|---|
| 525 | the C++ code required to subclass QAbstractXmlNodeModel, but even | 
|---|
| 526 | if the two are comparable, your custom C++ program can be used | 
|---|
| 527 | only for that one task, while your custom XML node model can be | 
|---|
| 528 | used by any XQuery that must navigate the file system. | 
|---|
| 529 |  | 
|---|
| 530 | The general approach to using XQuery to perform queries on non-XML | 
|---|
| 531 | data has been a three step process. In the first step, the data is | 
|---|
| 532 | loaded into a non-XML data model. In the second step, the non-XML | 
|---|
| 533 | data model is serialized as XML and output to XML (text) files. In | 
|---|
| 534 | the final step, an XML tool loads the XML files into a second, XML | 
|---|
| 535 | data model, where the XQueries can be performed.  The development | 
|---|
| 536 | cost of implementing this process is often high, and the three | 
|---|
| 537 | step system that results is inefficient because the two data | 
|---|
| 538 | models must be built and maintained separately. | 
|---|
| 539 |  | 
|---|
| 540 | With QtXmlPatterns, subclassing QAbstractXmlNodeModel eliminates | 
|---|
| 541 | the transformation required to convert the non-XML data model to | 
|---|
| 542 | the XML data model, because there is only ever one data model | 
|---|
| 543 | required. The non-XML data model presents the non-XML data to the | 
|---|
| 544 | query engine via the XML data model API. Also, since the query | 
|---|
| 545 | engine uses the API to access the QAbstractXmlNodeModel, the data | 
|---|
| 546 | model subclass can construct the elements, attributes and other | 
|---|
| 547 | data on demand, responding to the query's specific requests.  This | 
|---|
| 548 | can greatly improve efficiency, because it means the entire model | 
|---|
| 549 | might not have to be built. For example, in the file system model | 
|---|
| 550 | above, it is not necessary to build an instance for a whole | 
|---|
| 551 | XML file representing the whole file system. Instead nodes are | 
|---|
| 552 | created on demand, which also likely is a small subset of the file | 
|---|
| 553 | system. | 
|---|
| 554 |  | 
|---|
| 555 | Examples of other places where XQuery could be used in | 
|---|
| 556 | QtXmlPatterns to query non-XML data: | 
|---|
| 557 |  | 
|---|
| 558 | \list | 
|---|
| 559 |  | 
|---|
| 560 | \o The internal representation for word processor documents | 
|---|
| 561 |  | 
|---|
| 562 | \o The set of dependencies for a software build system | 
|---|
| 563 |  | 
|---|
| 564 | \o The hierarchy (or graph) that links a set of HTML documents | 
|---|
| 565 | from a web crawler | 
|---|
| 566 |  | 
|---|
| 567 | \o The images and meta-data in an image collection | 
|---|
| 568 |  | 
|---|
| 569 | \o The set of D-Bus interfaces available in a system | 
|---|
| 570 |  | 
|---|
| 571 | \o A QObject hierarchy, as seen in the \l{QObject XML Model | 
|---|
| 572 | Example} {QObject XML Model example}. | 
|---|
| 573 |  | 
|---|
| 574 | \endlist | 
|---|
| 575 |  | 
|---|
| 576 | See the QAbstractXmlNodeModel documentation for information about | 
|---|
| 577 | how to implement custom XML node models. | 
|---|
| 578 |  | 
|---|
| 579 | \section1 More on using QtXmlPatterns with non-XML Data | 
|---|
| 580 |  | 
|---|
| 581 | Subclassing QAbstractXmlNodeModel to let the query engine access | 
|---|
| 582 | non-XML data by the same API it uses for XML is the feature that | 
|---|
| 583 | enables QtXmlPatterns to query non-XML data with XQuery. It allows | 
|---|
| 584 | XQuery to be used as a mapping layer between different non-XML | 
|---|
| 585 | node models or between a non-XML node model and the built-in XML | 
|---|
| 586 | node model. Once the subclass(es) of QAbstractXmlNodeModel have | 
|---|
| 587 | been written, XQuery can be used to select a set of elements from | 
|---|
| 588 | one node model, transform the selected elements, and then write | 
|---|
| 589 | them out, either as XML using QXmlQuery::evaluateTo() and QXmlSerializer, | 
|---|
| 590 | or as some other format using a subclass of QAbstractXmlReceiver. | 
|---|
| 591 |  | 
|---|
| 592 | Consider a word processor application that must import and export | 
|---|
| 593 | data in several different formats. Rather than writing a lot of | 
|---|
| 594 | C++ code to convert each input format to an intermediate form, and | 
|---|
| 595 | more C++ code to convert the intermediate form back to each | 
|---|
| 596 | output format, one can implement a solution based on QtXmlPatterns | 
|---|
| 597 | that uses simple XQueries to transform each XML or non-XML format | 
|---|
| 598 | (e.g. MathFormula.xml below) to the intermediate form (e.g. the | 
|---|
| 599 | DocumentRepresentation node model class below), and more simple | 
|---|
| 600 | XQueries to transform the intermediate form back to each XML or | 
|---|
| 601 | non-XML format. | 
|---|
| 602 |  | 
|---|
| 603 | \image patternist-wordProcessor.png | 
|---|
| 604 |  | 
|---|
| 605 | Because CSV files are not XML, a subclass of QAbstractXmlNodeModel | 
|---|
| 606 | is used to present the CSV data to the XQuery engine as if it were | 
|---|
| 607 | XML. What are not shown are the subclasses of QAbstractXmlReceiver | 
|---|
| 608 | that would then send the selected elements into the | 
|---|
| 609 | DocumentRepresentation node model, and the subclasses of | 
|---|
| 610 | QAbstractXmlNodeModel that would ultimately write the output files | 
|---|
| 611 | in each format. | 
|---|
| 612 |  | 
|---|
| 613 | \section1 Security Considerations | 
|---|
| 614 |  | 
|---|
| 615 | \section2 Code Injection | 
|---|
| 616 |  | 
|---|
| 617 | XQuery is vulnerable to | 
|---|
| 618 | \l{http://en.wikipedia.org/wiki/Code_injection} {code injection | 
|---|
| 619 | attacks} in the same way as the SQL language. If an XQuery is | 
|---|
| 620 | constructed by concatenating strings, and the strings come from | 
|---|
| 621 | user input, the constructed XQuery could be malevolent. The best | 
|---|
| 622 | way to prevent code injection attacks is to not construct XQueries | 
|---|
| 623 | from user-written strings, but only accept user data input using | 
|---|
| 624 | QVariant and variable bindings. See QXmlQuery::bindVariable(). | 
|---|
| 625 |  | 
|---|
| 626 | The articles | 
|---|
| 627 | \l{http://www.ibm.com/developerworks/xml/library/x-xpathinjection.html} | 
|---|
| 628 | {Avoid the dangers of XPath injection}, by Robi Sen and | 
|---|
| 629 | \l{http://www.packetstormsecurity.org/papers/bypass/Blind_XPath_Injection_20040518.pdf} | 
|---|
| 630 | {Blind XPath Injection}, by Amit Klein, discuss the XQuery code | 
|---|
| 631 | injection problem in more detail. | 
|---|
| 632 |  | 
|---|
| 633 | \section2 Denial of Service Attacks | 
|---|
| 634 |  | 
|---|
| 635 | Applications using QtXmlPatterns are subject to the same | 
|---|
| 636 | limitations of software as other systems. Generally, these can not | 
|---|
| 637 | be checked. This means QtXmlPatterns does not prevent rogue | 
|---|
| 638 | queries from consuming too many resources. For example, a query | 
|---|
| 639 | could take too much time to execute or try to transfer too much | 
|---|
| 640 | data. A query could also do too much recursion, which could crash | 
|---|
| 641 | the system.  XQueries can do these things accidentally, but they | 
|---|
| 642 | can also be done as deliberate denial of service attacks. | 
|---|
| 643 |  | 
|---|
| 644 | \section1 Features and Conformance | 
|---|
| 645 |  | 
|---|
| 646 | \section2 XQuery 1.0 | 
|---|
| 647 |  | 
|---|
| 648 | QtXmlPatterns aims at being a | 
|---|
| 649 | \l{http://www.w3.org/TR/xquery/#id-xquery-conformance} {conformant | 
|---|
| 650 | XQuery processor}. It adheres to | 
|---|
| 651 | \l{http://www.w3.org/TR/xquery/#id-minimal-conformance} {Minimal | 
|---|
| 652 | Conformance} and supports the | 
|---|
| 653 | \l{http://www.w3.org/TR/xquery/#id-serialization-feature} | 
|---|
| 654 | {Serialization Feature} and the | 
|---|
| 655 | \l{http://www.w3.org/TR/xquery/#id-full-axis-feature} {Full Axis | 
|---|
| 656 | Feature}. QtXmlPatterns currently passes 97% of the tests in the | 
|---|
| 657 | \l{http://www.w3.org/XML/Query/test-suite} {XML Query Test Suite}. | 
|---|
| 658 | Areas where conformance may be questionable and where behavior may | 
|---|
| 659 | be changed in future releases include: | 
|---|
| 660 |  | 
|---|
| 661 | \list | 
|---|
| 662 |  | 
|---|
| 663 | \o Some corner cases involving namespaces and element constructors | 
|---|
| 664 | are incorrect. | 
|---|
| 665 |  | 
|---|
| 666 | \o XPath is a subset of XQuery and the implementation of | 
|---|
| 667 | QtXmlPatterns uses XPath 2.0 with XQuery 1.0. | 
|---|
| 668 |  | 
|---|
| 669 | \endlist | 
|---|
| 670 |  | 
|---|
| 671 | The specifications discusses conformance further: | 
|---|
| 672 | \l{http://www.w3.org/TR/xquery/}{XQuery 1.0: An XML Query | 
|---|
| 673 | Language}.  W3C's XQuery testing effort can be of interest as | 
|---|
| 674 | well, \l{http://www.w3.org/XML/Query/test-suite/}{XML Query Test | 
|---|
| 675 | Suite}. | 
|---|
| 676 |  | 
|---|
| 677 | Currently \c fn:collection() does not access any data set, and | 
|---|
| 678 | there is no API for providing data through the collection. As a | 
|---|
| 679 | result, evaluating \c fn:collection() returns the empty | 
|---|
| 680 | sequence. We intend to provide functionality for this in a future | 
|---|
| 681 | release of Qt. | 
|---|
| 682 |  | 
|---|
| 683 | Only queries encoded in UTF-8 are supported. | 
|---|
| 684 |  | 
|---|
| 685 | \section2 XSLT 2.0 | 
|---|
| 686 |  | 
|---|
| 687 | Partial support for XSLT was introduced in Qt 4.5. Future | 
|---|
| 688 | releases of QtXmlPatterns will aim to support these XSLT | 
|---|
| 689 | features: | 
|---|
| 690 |  | 
|---|
| 691 | \list | 
|---|
| 692 | \o Basic XSLT 2.0 processor | 
|---|
| 693 | \o Serialization feature | 
|---|
| 694 | \o Backwards Compatibility feature | 
|---|
| 695 | \endlist | 
|---|
| 696 |  | 
|---|
| 697 | For details, see \l{http://www.w3.org/TR/xslt20/#conformance}{XSL | 
|---|
| 698 | Transformations (XSLT) Version 2.0, 21 Conformance}. | 
|---|
| 699 |  | 
|---|
| 700 | \note In this release, XSLT support is considered experimental. | 
|---|
| 701 |  | 
|---|
| 702 | Unsupported or partially supported XSLT features are documented | 
|---|
| 703 | in the following table. The implementation of XSLT in Qt 4.5 can | 
|---|
| 704 | be seen as XSLT 1.0 but with the data model of XPath 2.0 and | 
|---|
| 705 | XSLT 2.0, and using the using the functionality of XPath 2.0 and | 
|---|
| 706 | its accompanying function library. When QtXmlPatterns encounters | 
|---|
| 707 | an unsupported or partially support feature, it will either report | 
|---|
| 708 | a syntax error or silently continue, unless otherwise noted in the | 
|---|
| 709 | table. | 
|---|
| 710 |  | 
|---|
| 711 | The implementation currently passes 42% of W3C's XSLT test suite, | 
|---|
| 712 | which focus on features introduced in XSLT 2.0. | 
|---|
| 713 |  | 
|---|
| 714 | \table | 
|---|
| 715 | \header | 
|---|
| 716 | \o XSL Feature | 
|---|
| 717 | \o Support Status | 
|---|
| 718 | \row | 
|---|
| 719 | \o \c xsl:key and \c fn:key() | 
|---|
| 720 | \o not supported | 
|---|
| 721 | \row | 
|---|
| 722 | \o \c xsl:include | 
|---|
| 723 | \o not supported | 
|---|
| 724 | \row | 
|---|
| 725 | \o \c xsl:import | 
|---|
| 726 | \o not supported | 
|---|
| 727 | \row | 
|---|
| 728 | \o \c xsl:copy | 
|---|
| 729 |  | 
|---|
| 730 | \o The \c copy-namespaces and \c inherit-namespaces attributes | 
|---|
| 731 | have no effect. For copied comments, attributes and | 
|---|
| 732 | processing instructions, the copy has the same node | 
|---|
| 733 | identity as the original. | 
|---|
| 734 |  | 
|---|
| 735 | \row | 
|---|
| 736 | \o \c xsl:copy-of | 
|---|
| 737 | \o The \c copy-namespaces attribute has no effect. | 
|---|
| 738 | \row | 
|---|
| 739 | \o \c fn:format-number() | 
|---|
| 740 | \o not supported | 
|---|
| 741 | \row | 
|---|
| 742 | \o \c xsl:message | 
|---|
| 743 | \o not supported | 
|---|
| 744 | \row | 
|---|
| 745 | \o \c xsl:use-when | 
|---|
| 746 | \o not supported | 
|---|
| 747 | \row | 
|---|
| 748 | \o \c Tunnel Parameters | 
|---|
| 749 | \o not supported | 
|---|
| 750 | \row | 
|---|
| 751 | \o \c xsl:attribute-set | 
|---|
| 752 | \o not supported | 
|---|
| 753 | \row | 
|---|
| 754 | \o \c xsl:decimal-format | 
|---|
| 755 | \o not supported | 
|---|
| 756 | \row | 
|---|
| 757 | \o \c xsl:fallback | 
|---|
| 758 | \o not supported | 
|---|
| 759 | \row | 
|---|
| 760 | \o \c xsl:apply-imports | 
|---|
| 761 | \o not supported | 
|---|
| 762 | \row | 
|---|
| 763 | \o \c xsl:character-map | 
|---|
| 764 | \o not supported | 
|---|
| 765 | \row | 
|---|
| 766 | \o \c xsl:number | 
|---|
| 767 | \o not supported | 
|---|
| 768 | \row | 
|---|
| 769 | \o \c xsl:namespace-alias | 
|---|
| 770 | \o not supported | 
|---|
| 771 | \row | 
|---|
| 772 | \o \c xsl:output | 
|---|
| 773 | \o not supported | 
|---|
| 774 | \row | 
|---|
| 775 | \o \c xsl:output-character | 
|---|
| 776 | \o not supported | 
|---|
| 777 | \row | 
|---|
| 778 | \o \c xsl:preserve-space | 
|---|
| 779 | \o not supported | 
|---|
| 780 | \row | 
|---|
| 781 | \o \c xsl:result-document | 
|---|
| 782 | \o not supported | 
|---|
| 783 | \row | 
|---|
| 784 | \o Patterns | 
|---|
| 785 | \o Complex patterns or patterns with predicates have issues. | 
|---|
| 786 | \row | 
|---|
| 787 | \o \c 2.0 Compatibility Mode | 
|---|
| 788 |  | 
|---|
| 789 | \o Stylesheets are interpreted as XSLT 2.0 stylesheets, even | 
|---|
| 790 | if the \c version attribute is in the XSLT source is | 
|---|
| 791 | 1.0. In other words, the version attribute is ignored. | 
|---|
| 792 |  | 
|---|
| 793 | \row | 
|---|
| 794 | \o Grouping | 
|---|
| 795 |  | 
|---|
| 796 | \o \c fn:current-group(), \c fn:grouping-key() and \c | 
|---|
| 797 | xsl:for-each-group. | 
|---|
| 798 |  | 
|---|
| 799 | \row | 
|---|
| 800 | \o Regexp elements | 
|---|
| 801 | \o \c xsl:analyze-string, \c xsl:matching-substring, | 
|---|
| 802 | \c xsl:non-matching-substring, and \c fn:regex-group() | 
|---|
| 803 | \row | 
|---|
| 804 | \o Date & Time formatting | 
|---|
| 805 | \o \c fn:format-dateTime(), \c fn:format-date() and fn:format-time(). | 
|---|
| 806 |  | 
|---|
| 807 | \row | 
|---|
| 808 | \o XPath Conformance | 
|---|
| 809 | \o Since XPath is a subset of XSLT, its issues are in affect too. | 
|---|
| 810 | \endtable | 
|---|
| 811 |  | 
|---|
| 812 | The QtXmlPatterns implementation of the XPath Data Model does not | 
|---|
| 813 | include entities (due to QXmlStreamReader not reporting them). | 
|---|
| 814 | This means that functions \c unparsed-entity-uri() and \c | 
|---|
| 815 | unparsed-entity-public-id() always return negatively. | 
|---|
| 816 |  | 
|---|
| 817 | \section2 XPath 2.0 | 
|---|
| 818 |  | 
|---|
| 819 | Since XPath 2.0 is a subset of XQuery 1.0, XPath 2.0 is | 
|---|
| 820 | supported. Areas where conformance may be questionable and, | 
|---|
| 821 | consequently, where behavior may be changed in future releases | 
|---|
| 822 | include: | 
|---|
| 823 |  | 
|---|
| 824 | \list | 
|---|
| 825 | \o Regular expression support is currently not conformant | 
|---|
| 826 | but follows Qt's QRegExp standard syntax. | 
|---|
| 827 |  | 
|---|
| 828 | \o Operators for \c xs:time, \c xs:date, and \c xs:dateTime | 
|---|
| 829 | are incomplete. | 
|---|
| 830 |  | 
|---|
| 831 | \o Formatting of very large or very small \c xs:double, \c | 
|---|
| 832 | xs:float, and \c xs:decimal values may be incorrect. | 
|---|
| 833 | \endlist | 
|---|
| 834 |  | 
|---|
| 835 | \section2 xml:id | 
|---|
| 836 |  | 
|---|
| 837 | Processing of XML files supports \c xml:id. This allows elements | 
|---|
| 838 | that have an attribute named \c xml:id to be looked up efficiently | 
|---|
| 839 | with the \c fn:id() function. See | 
|---|
| 840 | \l{http://www.w3.org/TR/xml-id/}{xml:id Version 1.0} for details. | 
|---|
| 841 |  | 
|---|
| 842 | \section2 Resource Loading | 
|---|
| 843 |  | 
|---|
| 844 | When QtXmlPatterns loads an XML resource, e.g., using the | 
|---|
| 845 | \c fn:doc() function, the following schemes are supported: | 
|---|
| 846 |  | 
|---|
| 847 | \table | 
|---|
| 848 | \header | 
|---|
| 849 | \o Scheme Name | 
|---|
| 850 | \o Description | 
|---|
| 851 | \row | 
|---|
| 852 | \o \c file | 
|---|
| 853 | \o Local files. | 
|---|
| 854 | \row | 
|---|
| 855 | \o \c data | 
|---|
| 856 |  | 
|---|
| 857 | \o The bytes are encoded in the URI itself. e.g., \c | 
|---|
| 858 | data:application/xml,%3Ce%2F%3E is \c <e/>. | 
|---|
| 859 |  | 
|---|
| 860 | \row | 
|---|
| 861 | \o \c ftp | 
|---|
| 862 | \o Resources retrieved via FTP. | 
|---|
| 863 | \row | 
|---|
| 864 | \o \c http | 
|---|
| 865 | \o Resources retrieved via HTTP. | 
|---|
| 866 | \row | 
|---|
| 867 | \o \c https | 
|---|
| 868 | \o Resources retrieved via HTTPS. This will succeed if no SSL | 
|---|
| 869 | errors are encountered. | 
|---|
| 870 | \row | 
|---|
| 871 | \o \c qrc | 
|---|
| 872 | \o Qt Resource files. Expressing it as an empty scheme, :/..., | 
|---|
| 873 | is not supported. | 
|---|
| 874 |  | 
|---|
| 875 | \endtable | 
|---|
| 876 |  | 
|---|
| 877 | \section2 XML | 
|---|
| 878 |  | 
|---|
| 879 | XML 1.0 and XML Namespaces 1.0 are supported, as opposed to the | 
|---|
| 880 | 1.1 versions. When a strings is passed to a query as a QString, | 
|---|
| 881 | the characters must be XML 1.0 characters. Otherwise, the behavior | 
|---|
| 882 | is undefined. This is not checked. | 
|---|
| 883 |  | 
|---|
| 884 | URIs are first passed to QAbstractUriResolver. Check | 
|---|
| 885 | QXmlQuery::setUriResolver() for possible rewrites. | 
|---|
| 886 |  | 
|---|
| 887 | */ | 
|---|
| 888 |  | 
|---|
| 889 | /*! | 
|---|
| 890 | \namespace QPatternist | 
|---|
| 891 | \brief The QPatternist namespace contains classes and functions required by the QtXmlPatterns module. | 
|---|
| 892 | \internal | 
|---|
| 893 | */ | 
|---|