1
/****************************************************************************
3
** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
4
** All rights reserved.
5
** Contact: Nokia Corporation (qt-info@nokia.com)
7
** This file is part of the QtXmlPatterns module of the Qt Toolkit.
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
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.
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.
28
** If you have questions regarding the use of this file, please contact
29
** Nokia at qt-info@nokia.com.
40
****************************************************************************/
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.
52
#ifndef Patternist_XsdTypeChecker_H
53
#define Patternist_XsdTypeChecker_H
55
#include <QtXmlPatterns/QSourceLocation>
57
#include "qschematype_p.h"
58
#include "qsourcelocationreflection_p.h"
59
#include "qxsdschemacontext_p.h"
70
* @short An implementation of SourceLocationReflection that takes a QSourceLocation.
72
* This is a convenience class which provides a QSourceLocation with a SourceLocationReflection
75
class XsdSchemaSourceLocationReflection : public SourceLocationReflection
78
XsdSchemaSourceLocationReflection(const QSourceLocation &location);
80
virtual const SourceLocationReflection *actualReflection() const;
81
virtual QSourceLocation sourceLocation() const;
84
const QSourceLocation m_sourceLocation;
88
* @short The class that provides methods for checking a string against a type.
90
* The class provides functionality for type-aware string handling.
96
* Creates a new type checker.
98
* @param context The schema context that is used for error reporting.
99
* @param namespaceBindings The namespace bindings that shall be used to check against xs:QName based types.
100
* @param location The source location that is used for error reporting.
102
XsdTypeChecker(const XsdSchemaContext::Ptr &context, const QVector<QXmlName> &namespaceBindings, const QSourceLocation &location);
105
* Destroys the type checker.
110
* Returns all facets for the given @p type.
112
* The list of facets is created by following the type hierarchy from xs:anyType down to the given type
113
* and merging the facets in each step.
115
static XsdFacet::Hash mergedFacetsForType(const SchemaType::Ptr &type, const XsdSchemaContext::Ptr &context);
118
* Returns the normalized value for the given @p value.
120
* The normalized value is the original value with all the white space facets
123
* @param value The original value.
124
* @param facets The hash of all facets of the values type.
126
static QString normalizedValue(const QString &value, const XsdFacet::Hash &facets);
129
* Checks whether the @p normalizedString is valid according the given @p type.
131
* @param normalizedString The string in normalized form (whitespace facets applied).
132
* @param type The type the string shall be tested against.
133
* @param errorMsg Contains the error message if the normalizedString does not match the type.
134
* @param boundType The type the data was bound to during validation.
136
* @note The @p boundType only differs from @p type if the type is derived from an based union value.
138
bool isValidString(const QString &normalizedString, const AnySimpleType::Ptr &type, QString &errorMsg, AnySimpleType::Ptr *boundType = 0) const;
141
* Returns whether the given @p value and @p otherValue are of @p type and are equal.
143
bool valuesAreEqual(const QString &value, const QString &otherValue, const AnySimpleType::Ptr &type) const;
146
Q_DISABLE_COPY(XsdTypeChecker)
149
* Checks the given value against the facets of @p type.
151
bool checkConstrainingFacets(const AtomicValue::Ptr &value, const QString &lexicalValue, const AnySimpleType::Ptr &type, QString &errorMsg) const;
152
bool checkConstrainingFacetsString(const QString &value, const XsdFacet::Hash &facets, const AnySimpleType::Ptr &type, QString &errorMsg) const;
153
bool checkConstrainingFacetsSignedInteger(long long value, const QString &lexicalValue, const XsdFacet::Hash &facets, QString &errorMsg) const;
154
bool checkConstrainingFacetsUnsignedInteger(unsigned long long value, const QString &lexicalValue, const XsdFacet::Hash &facets, QString &errorMsg) const;
155
bool checkConstrainingFacetsDouble(double value, const QString &lexicalValue, const XsdFacet::Hash &facets, QString &errorMsg) const;
156
bool checkConstrainingFacetsDecimal(const AtomicValue::Ptr &value, const QString &lexicalValue, const XsdFacet::Hash &facets, QString &errorMsg) const;
157
bool checkConstrainingFacetsDateTime(const QDateTime &value, const QString &lexicalValue, const XsdFacet::Hash &facets, const AnySimpleType::Ptr &type, QString &errorMsg) const;
158
bool checkConstrainingFacetsDuration(const AtomicValue::Ptr &value, const QString &lexicalValue, const XsdFacet::Hash &facets, QString &errorMsg) const;
159
bool checkConstrainingFacetsBoolean(bool value, const QString &lexicalValue, const XsdFacet::Hash &facets, QString &errorMsg) const;
160
bool checkConstrainingFacetsBinary(const QByteArray &value, const XsdFacet::Hash &facets, const AnySimpleType::Ptr &type, QString &errorMsg) const;
161
bool checkConstrainingFacetsQName(const QXmlName&, const QString &lexicalValue, const XsdFacet::Hash &facets, QString &errorMsg) const;
162
bool checkConstrainingFacetsNotation(const QXmlName &value, const XsdFacet::Hash &facets, QString &errorMsg) const;
163
bool checkConstrainingFacetsList(const QStringList &values, const QString &lexicalValue, const AnySimpleType::Ptr &itemType, const XsdFacet::Hash &facets, QString &errorMsg) const;
164
bool checkConstrainingFacetsUnion(const QString &value, const QString &lexicalValue, const XsdSimpleType::Ptr &simpleType, const XsdFacet::Hash &facets, QString &errorMsg) const;
167
* Creates an atomic value of @p type from the given string @p value.
169
AtomicValue::Ptr fromLexical(const QString &value, const SchemaType::Ptr &type, const ReportContext::Ptr &context, const SourceLocationReflection *const reflection) const;
172
* Converts a qualified name into a QXmlName according to the namespace
173
* mappings of the current node.
175
QXmlName convertToQName(const QString &name) const;
177
XsdSchemaContext::Ptr m_context;
178
XsdSchema::Ptr m_schema;
179
const NamePool::Ptr m_namePool;
180
QVector<QXmlName> m_namespaceBindings;
181
SourceLocationReflection* m_reflection;