author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 04 Oct 2010 01:19:32 +0300 | |
changeset 37 | 758a864f9613 |
parent 18 | 2f34d5167611 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtXmlPatterns module 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 |
#include "qpatternistlocale_p.h" |
|
43 |
||
44 |
#include "qoutputvalidator_p.h" |
|
45 |
||
46 |
QT_BEGIN_NAMESPACE |
|
47 |
||
48 |
using namespace QPatternist; |
|
49 |
||
50 |
OutputValidator::OutputValidator(QAbstractXmlReceiver *const receiver, |
|
51 |
const DynamicContext::Ptr &context, |
|
52 |
const SourceLocationReflection *const r, |
|
53 |
const bool isXSLT) : DelegatingSourceLocationReflection(r) |
|
54 |
, m_hasReceivedChildren(false) |
|
55 |
, m_receiver(receiver) |
|
56 |
, m_context(context) |
|
57 |
, m_isXSLT(isXSLT) |
|
58 |
{ |
|
59 |
Q_ASSERT(receiver); |
|
60 |
Q_ASSERT(context); |
|
61 |
} |
|
62 |
||
63 |
void OutputValidator::namespaceBinding(const QXmlName &nb) |
|
64 |
{ |
|
65 |
m_receiver->namespaceBinding(nb); |
|
66 |
} |
|
67 |
||
68 |
void OutputValidator::startElement(const QXmlName &name) |
|
69 |
{ |
|
70 |
m_hasReceivedChildren = false; |
|
71 |
m_receiver->startElement(name); |
|
72 |
m_attributes.clear(); |
|
73 |
} |
|
74 |
||
75 |
void OutputValidator::endElement() |
|
76 |
{ |
|
77 |
m_hasReceivedChildren = true; |
|
78 |
m_receiver->endElement(); |
|
79 |
} |
|
80 |
||
81 |
void OutputValidator::attribute(const QXmlName &name, |
|
82 |
const QStringRef &value) |
|
83 |
{ |
|
84 |
if(m_hasReceivedChildren) |
|
85 |
{ |
|
86 |
m_context->error(QtXmlPatterns::tr("It's not possible to add attributes after any other kind of node."), |
|
87 |
m_isXSLT ? ReportContext::XTDE0410 : ReportContext::XQTY0024, this); |
|
88 |
} |
|
89 |
else |
|
90 |
{ |
|
91 |
if(!m_isXSLT && m_attributes.contains(name)) |
|
92 |
{ |
|
93 |
m_context->error(QtXmlPatterns::tr("An attribute by name %1 has already been created.").arg(formatKeyword(m_context->namePool(), name)), |
|
94 |
ReportContext::XQDY0025, this); |
|
95 |
} |
|
96 |
else |
|
97 |
{ |
|
98 |
m_attributes.insert(name); |
|
99 |
m_receiver->attribute(name, value); |
|
100 |
} |
|
101 |
} |
|
102 |
} |
|
103 |
||
104 |
void OutputValidator::comment(const QString &value) |
|
105 |
{ |
|
106 |
m_hasReceivedChildren = true; |
|
107 |
m_receiver->comment(value); |
|
108 |
} |
|
109 |
||
110 |
void OutputValidator::characters(const QStringRef &value) |
|
111 |
{ |
|
112 |
m_hasReceivedChildren = true; |
|
113 |
m_receiver->characters(value); |
|
114 |
} |
|
115 |
||
116 |
void OutputValidator::processingInstruction(const QXmlName &name, |
|
117 |
const QString &value) |
|
118 |
{ |
|
119 |
m_hasReceivedChildren = true; |
|
120 |
m_receiver->processingInstruction(name, value); |
|
121 |
} |
|
122 |
||
123 |
void OutputValidator::item(const Item &outputItem) |
|
124 |
{ |
|
125 |
/* We can't send outputItem directly to m_receiver since its item() function |
|
126 |
* won't dispatch to this OutputValidator, but to itself. We're not sub-classing here, |
|
127 |
* we're delegating. */ |
|
128 |
||
129 |
if(outputItem.isNode()) |
|
130 |
sendAsNode(outputItem); |
|
131 |
else |
|
132 |
{ |
|
133 |
m_hasReceivedChildren = true; |
|
134 |
m_receiver->item(outputItem); |
|
135 |
} |
|
136 |
} |
|
137 |
||
138 |
void OutputValidator::startDocument() |
|
139 |
{ |
|
140 |
m_receiver->startDocument(); |
|
141 |
} |
|
142 |
||
143 |
void OutputValidator::endDocument() |
|
144 |
{ |
|
145 |
m_receiver->endDocument(); |
|
146 |
} |
|
147 |
||
148 |
void OutputValidator::atomicValue(const QVariant &value) |
|
149 |
{ |
|
150 |
Q_UNUSED(value); |
|
151 |
// TODO |
|
152 |
} |
|
153 |
||
154 |
void OutputValidator::endOfSequence() |
|
155 |
{ |
|
156 |
} |
|
157 |
||
158 |
void OutputValidator::startOfSequence() |
|
159 |
{ |
|
160 |
} |
|
161 |
||
162 |
QT_END_NAMESPACE |