1 | <?xml version="1.0" encoding="UTF-8" ?>
|
---|
2 | <!--
|
---|
3 | /****************************************************************************
|
---|
4 | **
|
---|
5 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
6 | ** All rights reserved.
|
---|
7 | ** Contact: Nokia Corporation ([email protected])
|
---|
8 | **
|
---|
9 | ** This file is part of the Patternist project on Qt Labs.
|
---|
10 | **
|
---|
11 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
12 | ** Commercial Usage
|
---|
13 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
14 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
15 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
16 | ** a written agreement between you and Nokia.
|
---|
17 | **
|
---|
18 | ** GNU Lesser General Public License Usage
|
---|
19 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
20 | ** General Public License version 2.1 as published by the Free Software
|
---|
21 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
22 | ** packaging of this file. Please review the following information to
|
---|
23 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
24 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
25 | **
|
---|
26 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
27 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
29 | **
|
---|
30 | ** GNU General Public License Usage
|
---|
31 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
32 | ** General Public License version 3.0 as published by the Free Software
|
---|
33 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
34 | ** packaging of this file. Please review the following information to
|
---|
35 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
36 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
37 | **
|
---|
38 | ** If you have questions regarding the use of this file, please contact
|
---|
39 | ** Nokia at [email protected].
|
---|
40 | ** $QT_END_LICENSE$
|
---|
41 | **
|
---|
42 | ***************************************************************************
|
---|
43 | */
|
---|
44 | -->
|
---|
45 |
|
---|
46 | <xsl:stylesheet
|
---|
47 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
48 | xmlns:h="http://www.w3.org/1999/xhtml"
|
---|
49 | version="1.0">
|
---|
50 |
|
---|
51 | <xsl:output omit-xml-declaration="yes"/>
|
---|
52 |
|
---|
53 | <!--
|
---|
54 | This code open the following specifications:
|
---|
55 |
|
---|
56 | - XQuery 1.0 and XPath 2.0 Functions and Operators
|
---|
57 | - XML Path Language (XPath) 2.0
|
---|
58 | - XSL Transformations (XSLT) Version 2.0
|
---|
59 | - XQuery 1.0: An XML Query Language
|
---|
60 |
|
---|
61 | and extracts the error codes as well as their documentation and exports
|
---|
62 | them as enum values into a C++ enumerator called ErrorCode.
|
---|
63 |
|
---|
64 | NOTE: Be aware of binary compatibility when using this stylesheet.
|
---|
65 | -->
|
---|
66 |
|
---|
67 | <!--
|
---|
68 | <xsl:variable name="xslt20" select="document('xslt20.html')"/>
|
---|
69 | -->
|
---|
70 | <xsl:variable name="xslt20" select="document('http://www.w3.org/TR/xslt20')"/>
|
---|
71 |
|
---|
72 | <!--
|
---|
73 | <xsl:variable name="xqfo" select="document('xqfo.html')"/>
|
---|
74 | -->
|
---|
75 | <xsl:variable name="xqfo" select="document('http://www.w3.org/TR/xpath-functions/')"/>
|
---|
76 |
|
---|
77 | <!--
|
---|
78 | <xsl:variable name="xq" select="document('xq.html')"/>
|
---|
79 | -->
|
---|
80 | <xsl:variable name="xq" select="document('http://www.w3.org/TR/xquery/')"/>
|
---|
81 |
|
---|
82 | <!--
|
---|
83 | <xsl:variable name="ser" select="document('ser.html')"/>
|
---|
84 | -->
|
---|
85 | <xsl:variable name="ser" select="document('http://www.w3.org/TR/xslt-xquery-serialization/')"/>
|
---|
86 |
|
---|
87 | <!--
|
---|
88 | *********************************************
|
---|
89 | *********************************************
|
---|
90 | -->
|
---|
91 | <xsl:template match="/"><xsl:text disable-output-escaping="yes"
|
---|
92 | ><![CDATA[/****************************************************************************
|
---|
93 | **
|
---|
94 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
95 | ** All rights reserved.
|
---|
96 | ** Contact: Nokia Corporation ([email protected])
|
---|
97 | **
|
---|
98 | ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
|
---|
99 | **
|
---|
100 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
101 | ** Commercial Usage
|
---|
102 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
103 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
104 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
105 | ** a written agreement between you and Nokia.
|
---|
106 | **
|
---|
107 | ** GNU Lesser General Public License Usage
|
---|
108 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
109 | ** General Public License version 2.1 as published by the Free Software
|
---|
110 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
111 | ** packaging of this file. Please review the following information to
|
---|
112 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
113 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
114 | **
|
---|
115 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
116 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
117 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
118 | **
|
---|
119 | ** GNU General Public License Usage
|
---|
120 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
121 | ** General Public License version 3.0 as published by the Free Software
|
---|
122 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
123 | ** packaging of this file. Please review the following information to
|
---|
124 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
125 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
126 | **
|
---|
127 | ** If you have questions regarding the use of this file, please contact
|
---|
128 | ** Nokia at [email protected].
|
---|
129 | ** $QT_END_LICENSE$
|
---|
130 | **
|
---|
131 | ****************************************************************************/
|
---|
132 |
|
---|
133 | //
|
---|
134 | // W A R N I N G
|
---|
135 | // -------------
|
---|
136 | //
|
---|
137 | // This file is not part of the Qt API. It exists purely as an
|
---|
138 | // implementation detail. This header file may change from version to
|
---|
139 | // version without notice, or even be removed.
|
---|
140 | //
|
---|
141 | // We mean it.
|
---|
142 |
|
---|
143 | #ifndef Patternist_ReportContext_H
|
---|
144 | #define Patternist_ReportContext_H
|
---|
145 |
|
---|
146 | #include <QSharedData>
|
---|
147 | #include <QAbstractUriResolver>
|
---|
148 | #include <QSourceLocation>
|
---|
149 |
|
---|
150 | #include "qnamepool_p.h"
|
---|
151 | #include "qxmlname.h"
|
---|
152 |
|
---|
153 | QT_BEGIN_HEADER
|
---|
154 |
|
---|
155 | QT_BEGIN_NAMESPACE
|
---|
156 |
|
---|
157 | class QAbstractMessageHandler;
|
---|
158 | class QSourceLocation;
|
---|
159 | class QString;
|
---|
160 |
|
---|
161 | namespace QPatternist
|
---|
162 | {
|
---|
163 | class SourceLocationReflection;
|
---|
164 |
|
---|
165 | /**
|
---|
166 | * @short A callback for reporting errors.
|
---|
167 | *
|
---|
168 | * ReportContext receives messages of various severity and type via its
|
---|
169 | * functions warning() and error(). In turn, ReportContext create Message instances
|
---|
170 | * and submit them to the QAbstractMessageHandler instance returned by messageHandler().
|
---|
171 | *
|
---|
172 | * The Message attributes are set as follows:
|
---|
173 | *
|
---|
174 | * - Message::description() - A translated, human-readable description
|
---|
175 | * - Message::type() - Message::Error if a static, dynamic or type error was encountered
|
---|
176 | * that halted compilation or evaluation, or Message::Warning in case of a warning
|
---|
177 | * - Message::identifier() - This is a URI consisting of the error namespace with the
|
---|
178 | * error code as fragment. For example, a Message representing a syntax error
|
---|
179 | * would return the type "http://www.w3.org/2005/xqt-errors#XPST0003". The convenience
|
---|
180 | * function codeFromURI() can be used to extract the error code. The error namespace
|
---|
181 | * is typically the namespace for XPath and XQuery errors(as in the previous example), but
|
---|
182 | * can also be user defined.
|
---|
183 | *
|
---|
184 | * @see <a href="http://www.w3.org/TR/xpath20/#id-identifying-errors">XML Path Language
|
---|
185 | * (XPath) 2.0, 2.3.2 Identifying and Reporting Errors</a>
|
---|
186 | * @see <a href="http://www.w3.org/TR/xpath-functions/#func-error">XQuery 1.0 and
|
---|
187 | * XPath 2.0 Functions and Operators, 3 The Error Function</a>
|
---|
188 | * @author Frans Englich <[email protected]>
|
---|
189 | * @warning This file is auto-generated from extractErrorCodes.xsl. Any
|
---|
190 | * modifications done to this file are lost.
|
---|
191 | */
|
---|
192 | class Q_AUTOTEST_EXPORT ReportContext : public QSharedData
|
---|
193 | {
|
---|
194 | public:
|
---|
195 | typedef QHash<const SourceLocationReflection *, QSourceLocation> LocationHash;
|
---|
196 |
|
---|
197 | /**
|
---|
198 | * A smart pointer wrapping ReportContext instances.
|
---|
199 | */
|
---|
200 | typedef QExplicitlySharedDataPointer<ReportContext> Ptr;
|
---|
201 |
|
---|
202 | /**
|
---|
203 | * @short Default constructors.
|
---|
204 | *
|
---|
205 | * For some reason GCC fails to synthesize it, so we provide an empty
|
---|
206 | * one here.
|
---|
207 | */
|
---|
208 | inline ReportContext() {}
|
---|
209 |
|
---|
210 | virtual ~ReportContext();
|
---|
211 |
|
---|
212 | /**
|
---|
213 | * Error codes that corresponds to the error codes defined in the
|
---|
214 | * relevant specifications. They are used throughout the API for
|
---|
215 | * identifying error conditions.
|
---|
216 | *
|
---|
217 | * While strings could have been used for identifying errors, enums
|
---|
218 | * reduces bugs by providing type safety.
|
---|
219 | *
|
---|
220 | * @see <a href="http://www.w3.org/TR/xpath20/#errors">XML
|
---|
221 | * Path Language (XPath) 2.0, 2.3 Error Handling</a>
|
---|
222 | * @see <a href="http://www.w3.org/TR/xpath-functions/#d1e10985">XQuery 1.0
|
---|
223 | * and XPath 2.0 Functions and Operators, C Error Summary</a>
|
---|
224 | * @see <a href="http://www.w3.org/TR/xslt20/#error-summary">XSL Transformations
|
---|
225 | * (XSLT) Version 2.0, E Summary of Error Conditions (Non-Normative)</a>
|
---|
226 | * @note The enumerator values' Doxygen documentation is copied from the
|
---|
227 | * W3C documents
|
---|
228 | * <a href="http://www.w3.org/TR/xpath-functions">XQuery 1.0 and XPath
|
---|
229 | * 2.0 Functions and Operators</a>,
|
---|
230 | * <a href="http://www.w3.org/TR/xpath20">XML Path Language (XPath) 2.0</a>, and
|
---|
231 | * <a href="http://www.w3.org/TR/xslt20/">XSL Transformations (XSLT)
|
---|
232 | * Version 2.0</a>, respectively. The doxygen documentation is therefore covered
|
---|
233 | * by the following legal notice:
|
---|
234 | * "Copyright @ 2005 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
|
---|
235 | * <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
|
---|
236 | * <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and
|
---|
237 | * <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document
|
---|
238 | * use</a> rules apply."
|
---|
239 | * @warning This enumerator is auto-generated from the relevant specifications
|
---|
240 | * by the XSL-T stylesheet extractErrorCodes.xsl. Hence, any modifications
|
---|
241 | * done to this file, in contrary to the stylesheet, are therefore lost.
|
---|
242 | */]]></xsl:text>
|
---|
243 | enum ErrorCode
|
---|
244 | {
|
---|
245 | /**
|
---|
246 | * XML Schema error code.
|
---|
247 | */
|
---|
248 | XSDError,
|
---|
249 |
|
---|
250 | <!-- The order of the calls is significant. The templates takes into account
|
---|
251 | to avoid the last comma(extractXSLT20 does this). -->
|
---|
252 | <xsl:call-template name="extractXQuery10"/>
|
---|
253 | <xsl:call-template name="extractXQueryFO"/>
|
---|
254 | <xsl:call-template name="extractSerialization"/>
|
---|
255 | <xsl:call-template name="extractXSLT20"/>
|
---|
256 | };
|
---|
257 | <xsl:text disable-output-escaping="yes"><![CDATA[
|
---|
258 | /**
|
---|
259 | * Issues a warning, should not be used excessively. This can
|
---|
260 | * be used to communicate that a certain implementation defined
|
---|
261 | * feature is unsupported or that a certain expression most likely
|
---|
262 | * doesn't do what the users wants, to name a few examples.
|
---|
263 | *
|
---|
264 | * @see <a href="http://www.w3.org/TR/xpath20/#errors">XML Path Language (XPath) 2.0,
|
---|
265 | * 2.3 Error Handling</a>
|
---|
266 | * @param message the message to be read by the user.
|
---|
267 | * @param sourceLocation the location of where the warning originates from.
|
---|
268 | */
|
---|
269 | void warning(const QString &message, const QSourceLocation &sourceLocation = QSourceLocation());
|
---|
270 |
|
---|
271 | /**
|
---|
272 | * Issues an error. May be used at the static analysis phase or
|
---|
273 | * the dynamic evaluation phase.
|
---|
274 | *
|
---|
275 | * For SourceLocationReflection instances, the overload taking an SouourceLocationReflection should be used.
|
---|
276 | *
|
---|
277 | * @see <a href="http://www.w3.org/TR/xpath20/#errors">XML Path Language (XPath) 2.0,
|
---|
278 | * 2.3 Error Handling</a>
|
---|
279 | * @param message the message to be read by the user.
|
---|
280 | * @param errorCode identifies the error condition, as described
|
---|
281 | * @param sourceLocation the location of where the error originates from
|
---|
282 | * in "XML Path Language (XPath) 2.0" section "G Error Conditions"
|
---|
283 | */
|
---|
284 | void error(const QString &message,
|
---|
285 | const ReportContext::ErrorCode errorCode,
|
---|
286 | const QSourceLocation &sourceLocation);
|
---|
287 |
|
---|
288 | /**
|
---|
289 | * Overload.
|
---|
290 | *
|
---|
291 | * Same as the above, but passes the SourceLocationReflection as reference for error reporting.
|
---|
292 | */
|
---|
293 | void error(const QString &message,
|
---|
294 | const ReportContext::ErrorCode errorCode,
|
---|
295 | const SourceLocationReflection *reflection);
|
---|
296 |
|
---|
297 | /**
|
---|
298 | * Issues an error which is not identified in the XPath specifications. This function
|
---|
299 | * is among other things used for implementing the <tt>fn:error()</tt> function.
|
---|
300 | */
|
---|
301 | void error(const QString &message,
|
---|
302 | const QXmlName qName,
|
---|
303 | const SourceLocationReflection *const r);
|
---|
304 |
|
---|
305 | /**
|
---|
306 | * @return the QAbstractMessageHandler which functions such as warning() and
|
---|
307 | * error() should submit messages to. This function
|
---|
308 | * may never return @c null; a valid QAbstractMessageHandler pointer must always be returned.
|
---|
309 | */
|
---|
310 | virtual QAbstractMessageHandler *messageHandler() const = 0;
|
---|
311 |
|
---|
312 | virtual NamePool::Ptr namePool() const = 0;
|
---|
313 |
|
---|
314 | /**
|
---|
315 | * Returns a string representation of the error code @p code.
|
---|
316 | *
|
---|
317 | * @see ReportContext::ErrorCode
|
---|
318 | * @param errorCode identifies the error condition, as described
|
---|
319 | * in <a href="http://www.w3.org/TR/xpath20/#id-errors">XML Path
|
---|
320 | * Language (XPath) 2.0, G Error Conditions</a>
|
---|
321 | */
|
---|
322 | static QString codeToString(const ReportContext::ErrorCode errorCode);
|
---|
323 |
|
---|
324 | /**
|
---|
325 | * @returns the error code part of @p typeURI and sets @p uri to the error namespace. Note
|
---|
326 | * that the error namespace not necessarily is the namespace for XPath and
|
---|
327 | * XQuery errors, http://www.w3.org/2005/xqt-errors, but can be user defined.
|
---|
328 | */
|
---|
329 | static QString codeFromURI(const QString &typeURI,
|
---|
330 | QString &uri);
|
---|
331 |
|
---|
332 | /**
|
---|
333 | * @short Returns the source location applying for @p reflection.
|
---|
334 | */
|
---|
335 | virtual QSourceLocation locationFor(const SourceLocationReflection *const reflection) const = 0;
|
---|
|
---|