Qt 4.8
qxslttokenizer_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 //
43 // W A R N I N G
44 // -------------
45 //
46 // This file is not part of the Qt API. It exists purely as an
47 // implementation detail. This header file may change from version to
48 // version without notice, or even be removed.
49 //
50 // We mean it.
51 
52 #ifndef Patternist_XSLTTokenizer_H
53 #define Patternist_XSLTTokenizer_H
54 
55 #include <QQueue>
56 #include <QStack>
57 #include <QUrl>
58 
59 #include "qmaintainingreader_p.h"
60 #include "qreportcontext_p.h"
61 #include "qtokenizer_p.h"
62 #include "qxslttokenlookup_p.h"
63 
65 
67 
68 namespace QPatternist
69 {
81  {
82  public:
83  inline SingleTokenContainer(const Tokenizer::Token &token,
84  const YYLTYPE &location);
85 
86  virtual Tokenizer::Token nextToken(YYLTYPE *const sourceLocator);
87  private:
91  };
92 
94  const YYLTYPE &location) : m_token(token)
95  , m_location(location)
96  , m_hasDelivered(false)
97  {
98  }
99 
112  class XSLTTokenizer : public Tokenizer
113  , private MaintainingReader<XSLTTokenLookup>
114  {
115  public:
119  XSLTTokenizer(QIODevice *const queryDevice,
120  const QUrl &location,
121  const ReportContext::Ptr &context,
122  const NamePool::Ptr &np);
123 
124  virtual Token nextToken(YYLTYPE *const sourceLocator);
125 
129  virtual int commenceScanOnly();
130 
134  virtual void resumeTokenizationFrom(const int position);
135 
136  virtual void setParserContext(const ParserContext::Ptr &parseInfo);
137 
138  virtual QUrl documentURI() const
139  {
140  return queryURI();
141  }
142 
143  protected:
144  virtual bool isAnyAttributeAllowed() const;
145 
146  private:
147  inline void validateElement() const;
148 
149  YYLTYPE currentSourceLocator() const;
150 
151  enum State
152  {
155  InsideSequenceConstructor
156  };
157 
159  {
165  WithParamVariable
166  };
167 
168  void queueNamespaceDeclarations(TokenSource::Queue *const ts,
169  QStack<Token> *const target,
170  const bool isDeclaration = false);
171 
172  inline void queueToken(const Token &token,
173  TokenSource::Queue *const ts);
174  void queueEmptySequence(TokenSource::Queue *const to);
175  void queueSequenceType(const QString &expr);
180  void queueSimpleContentConstructor(const ReportContext::ErrorCode code,
181  const bool emptynessAllowed,
182  TokenSource::Queue *const to,
183  const bool selectOnlyFirst = false);
188  void queueAVT(const QString &expr,
189  TokenSource::Queue *const to);
190 
191  void hasWrittenExpression(bool &beacon);
192  void commencingExpression(bool &hasWrittenExpression,
193  TokenSource::Queue *const to);
194 
195  void outsideDocumentElement();
196  void insideChoose(TokenSource::Queue *const to);
197  void insideFunction();
198 
199  bool attributeYesNo(const QString &localName) const;
200 
205  void parseFallbacksOnly();
206 
214  bool isStylesheetElement() const;
215 
223  bool isElement(const NodeName &name) const;
224 
229  void queueTextConstructor(QString &chars,
230  bool &hasWrittenExpression,
231  TokenSource::Queue *const to);
232 
238  void insideStylesheetModule();
239  void insideTemplate();
240 
246  void queueExpression(const QString &expr,
247  TokenSource::Queue *const to,
248  const bool wrapWithParantheses = true);
249 
250  void skipBodyOfParam(const ReportContext::ErrorCode code);
251 
252  void queueParams(const NodeName parentName,
253  TokenSource::Queue *const to);
254 
258  void queueWithParams(const NodeName parentName,
259  TokenSource::Queue *const to,
260  const bool initialAdvance = true);
261 
267  void queueVariableDeclaration(const VariableType variableType,
268  TokenSource::Queue *const to);
269 
279  bool skipSubTree(const bool exitOnContent = false);
280 
299  bool queueSelectOrSequenceConstructor(const ReportContext::ErrorCode code,
300  const bool emptynessAllowed,
301  TokenSource::Queue *const to,
302  const QXmlStreamAttributes *const atts = 0,
303  const bool queueEmptyOnEmpty = true);
304 
314  bool insideSequenceConstructor(TokenSource::Queue *const to,
315  const bool initialAdvance = true,
316  const bool queueEmptyOnEmpty = true);
317 
318  bool insideSequenceConstructor(TokenSource::Queue *const to,
319  QStack<Token> &queueOnExit,
320  const bool initialAdvance = true,
321  const bool queueEmptyOnEmpty = true);
322 
323  void insideAttributeSet();
324  void pushState(const State nextState);
325  void leaveState();
326 
345  void handleStandardAttributes(const bool isXSLTElement);
346 
350  inline void queueOnExit(QStack<Token> &source,
351  TokenSource::Queue *const destination);
352 
363  void handleValidationAttributes(const bool isLRE) const;
364 
365  void unexpectedContent(const ReportContext::ErrorCode code = ReportContext::XTSE0010) const;
366 
367  void checkForParseError() const;
368 
369  inline void startStorageOfCurrent(TokenSource::Queue *const to);
370  inline void endStorageOfCurrent(TokenSource::Queue *const to);
371 
376  void handleXSLTVersion(TokenSource::Queue *const to,
377  QStack<Token> *const queueOnExit,
378  const bool isXSLTElement,
379  const QXmlStreamAttributes *atts = 0,
380  const bool generateCode = true,
381  const bool setGlobalVersion = false);
382 
386  void handleXMLBase(TokenSource::Queue *const to,
387  QStack<Token> *const queueOnExit,
388  const bool isInstruction = true,
389  const QXmlStreamAttributes *atts = 0);
390 
398  QString readElementText();
399 
412  void queueSorting(const bool oneSortRequired,
413  TokenSource::Queue *const to,
414  const bool speciallyTreatWhitespace = false);
415 
416  static ElementDescription<XSLTTokenLookup>::Hash createElementDescriptions();
417  static QHash<QString, int> createValidationAlternatives();
418  static QSet<NodeName> createStandardAttributes();
419 
425  bool readToggleAttribute(const QString &attributeName,
426  const QString &isTrue,
427  const QString &isFalse,
428  const QXmlStreamAttributes *const atts = 0) const;
429 
430  int readAlternativeAttribute(const QHash<QString, int> &alternatives,
431  const QXmlStreamAttribute &attr) const;
432 
437  inline bool whitespaceToSkip() const;
438 
443 
445  {
448  NormalProcessing
449  };
450 
464 
469  inline bool isXSLT() const;
470 
472 
474  };
475 }
476 
478 
480 
481 #endif
TokenSource::Queue m_tokenSource
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
const Tokenizer::Token m_token
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
virtual Tokenizer::Token nextToken(YYLTYPE *const sourceLocator)
The QExplicitlySharedDataPointer class represents a pointer to an explicitly shared object...
Definition: qshareddata.h:136
Tokenizes XSL-T 2.0 documents.
const NamePool::Ptr m_namePool
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
The QXmlStreamAttribute class represents a single XML attribute.
Definition: qxmlstream.h:135
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
A TokenSource which contains one Tokenizer::Token.
const char * name
The namespace for the internal API of QtXmlPatterns.
QStack< ProcessMode > m_processingMode
The State element defines configurations of objects and properties.
Base class for tokenizers that reads XML formats. This is XSLTTokenizer, and the W3C XML Schema parse...
const QHash< QString, int > m_validationAlternatives
The QXmlStreamAttributes class represents a vector of QXmlStreamAttribute.
Definition: qxmlstream.h:169
static QTestResult::TestLocation location
Definition: qtestresult.cpp:63
Base class for components that needs to return tokens.
Base class for all tokenizers.
Definition: qtokenizer_p.h:155
The QIODevice class is the base interface class of all I/O devices in Qt.
Definition: qiodevice.h:66
#define QT_END_HEADER
Definition: qglobal.h:137
SingleTokenContainer(const Tokenizer::Token &token, const YYLTYPE &location)
ParserContext::Ptr m_parseInfo
Contains functions and classes used by the parser and tokenizer.
virtual QUrl documentURI() const
Returns the location of the document that MaintainingReader is parsing. Used for error reporting...