summaryrefslogtreecommitdiff
path: root/src/xmlpatterns/janitors
diff options
context:
space:
mode:
Diffstat (limited to 'src/xmlpatterns/janitors')
-rw-r--r--src/xmlpatterns/janitors/janitors.pri13
-rw-r--r--src/xmlpatterns/janitors/qargumentconverter.cpp104
-rw-r--r--src/xmlpatterns/janitors/qargumentconverter_p.h103
-rw-r--r--src/xmlpatterns/janitors/qatomizer.cpp125
-rw-r--r--src/xmlpatterns/janitors/qatomizer_p.h110
-rw-r--r--src/xmlpatterns/janitors/qcardinalityverifier.cpp224
-rw-r--r--src/xmlpatterns/janitors/qcardinalityverifier_p.h128
-rw-r--r--src/xmlpatterns/janitors/qebvextractor.cpp90
-rw-r--r--src/xmlpatterns/janitors/qebvextractor_p.h109
-rw-r--r--src/xmlpatterns/janitors/qitemverifier.cpp122
-rw-r--r--src/xmlpatterns/janitors/qitemverifier_p.h103
-rw-r--r--src/xmlpatterns/janitors/quntypedatomicconverter.cpp113
-rw-r--r--src/xmlpatterns/janitors/quntypedatomicconverter_p.h127
13 files changed, 1471 insertions, 0 deletions
diff --git a/src/xmlpatterns/janitors/janitors.pri b/src/xmlpatterns/janitors/janitors.pri
new file mode 100644
index 0000000..25de3a4
--- /dev/null
+++ b/src/xmlpatterns/janitors/janitors.pri
@@ -0,0 +1,13 @@
+HEADERS += $$PWD/qargumentconverter_p.h \
+ $$PWD/qatomizer_p.h \
+ $$PWD/qcardinalityverifier_p.h \
+ $$PWD/qebvextractor_p.h \
+ $$PWD/qitemverifier_p.h \
+ $$PWD/quntypedatomicconverter_p.h
+
+SOURCES += $$PWD/qargumentconverter.cpp \
+ $$PWD/qatomizer.cpp \
+ $$PWD/qcardinalityverifier.cpp \
+ $$PWD/qebvextractor.cpp \
+ $$PWD/qitemverifier.cpp \
+ $$PWD/quntypedatomicconverter.cpp
diff --git a/src/xmlpatterns/janitors/qargumentconverter.cpp b/src/xmlpatterns/janitors/qargumentconverter.cpp
new file mode 100644
index 0000000..bf4c431
--- /dev/null
+++ b/src/xmlpatterns/janitors/qargumentconverter.cpp
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtXmlPatterns module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qitemmappingiterator_p.h"
+#include "qsequencemappingiterator_p.h"
+
+#include "qargumentconverter_p.h"
+
+QT_BEGIN_NAMESPACE
+
+using namespace QPatternist;
+
+ArgumentConverter::ArgumentConverter(const Expression::Ptr &operand,
+ const ItemType::Ptr &reqType) : UntypedAtomicConverter(operand, reqType)
+{
+}
+
+ExpressionVisitorResult::Ptr ArgumentConverter::accept(const ExpressionVisitor::Ptr &visitor) const
+{
+ return visitor->visit(this);
+}
+
+Item::Iterator::Ptr ArgumentConverter::mapToSequence(const Item &item,
+ const DynamicContext::Ptr &context) const
+{
+ if(item.isAtomicValue() && !BuiltinTypes::xsUntypedAtomic->xdtTypeMatches(item.type()))
+ return makeSingletonIterator(item);
+ else
+ {
+ /* We're using UntypedAtomicConverter::mapToItem(). */
+ return makeItemMappingIterator<Item>(ConstPtr(this),
+ item.sequencedTypedValue(),
+ context);
+ }
+}
+
+Item::Iterator::Ptr ArgumentConverter::evaluateSequence(const DynamicContext::Ptr &context) const
+{
+ return makeSequenceMappingIterator<Item>(ConstPtr(this),
+ m_operand->evaluateSequence(context),
+ context);
+}
+
+Item ArgumentConverter::evaluateSingleton(const DynamicContext::Ptr &context) const
+{
+ const Item item(m_operand->evaluateSingleton(context));
+
+ if(item)
+ return mapToItem(item, context);
+ else /* Empty is allowed. ArgumentConverter doesn't care about cardinality. */
+ return Item();
+}
+
+SequenceType::List ArgumentConverter::expectedOperandTypes() const
+{
+ SequenceType::List result;
+ result.append(CommonSequenceTypes::ZeroOrMoreItems);
+ return result;
+}
+
+SequenceType::Ptr ArgumentConverter::staticType() const
+{
+ return CommonSequenceTypes::ZeroOrMoreAtomicTypes;
+}
+
+QT_END_NAMESPACE
diff --git a/src/xmlpatterns/janitors/qargumentconverter_p.h b/src/xmlpatterns/janitors/qargumentconverter_p.h
new file mode 100644
index 0000000..244507f
--- /dev/null
+++ b/src/xmlpatterns/janitors/qargumentconverter_p.h
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtXmlPatterns module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+
+#ifndef Patternist_ArgumentConverter_H
+#define Patternist_ArgumentConverter_H
+
+#include "quntypedatomicconverter_p.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+namespace QPatternist
+{
+
+ /**
+ * @short UntypedAtomicConverter for ArgumentReference, if needed.
+ *
+ * If an argument inside a user function has no type declared, its type
+ * is @c item(). It's atomized type would be inferred to @c
+ * xs:anyAtomicType, but that is not necessarily correct, since the actual
+ * value can be anything, nodes or atomic values.
+ *
+ * This extremely dynamic case is handled by ArgumentConverter which is inserted for
+ * ArgumentReference that has the static type @c item(), when atomic value are asked
+ * for. At runtime it atomizes/let values through appropriately.
+ *
+ * @author Frans Englich <frans.englich@nokia.com>
+ * @ingroup Patternist_expressions
+ */
+ class ArgumentConverter : public UntypedAtomicConverter
+ {
+ public:
+ ArgumentConverter(const Expression::Ptr &operand,
+ const ItemType::Ptr &reqType);
+
+ virtual Item evaluateSingleton(const DynamicContext::Ptr &) const;
+ virtual Item::Iterator::Ptr evaluateSequence(const DynamicContext::Ptr &) const;
+ virtual ExpressionVisitorResult::Ptr accept(const ExpressionVisitor::Ptr &visitor) const;
+ inline Item::Iterator::Ptr mapToSequence(const Item &item,
+ const DynamicContext::Ptr &context) const;
+ virtual SequenceType::List expectedOperandTypes() const;
+ virtual SequenceType::Ptr staticType() const;
+
+ private:
+ typedef QExplicitlySharedDataPointer<const ArgumentConverter> ConstPtr;
+
+ };
+}
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/xmlpatterns/janitors/qatomizer.cpp b/src/xmlpatterns/janitors/qatomizer.cpp
new file mode 100644
index 0000000..ae4b597
--- /dev/null
+++ b/src/xmlpatterns/janitors/qatomizer.cpp
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtXmlPatterns module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qatomictype_p.h"
+#include "qbuiltintypes_p.h"
+#include "qcommonsequencetypes_p.h"
+#include "qgenericsequencetype_p.h"
+#include "qsequencemappingiterator_p.h"
+
+#include "qatomizer_p.h"
+
+QT_BEGIN_NAMESPACE
+
+using namespace QPatternist;
+
+Atomizer::Atomizer(const Expression::Ptr &operand) : SingleContainer(operand)
+{
+}
+
+Item::Iterator::Ptr Atomizer::mapToSequence(const Item &item, const DynamicContext::Ptr &) const
+{
+ /* Function & Operators, 2.4.2 fn:data, says "If the node does not have a
+ * typed value an error is raised [err:FOTY0012]."
+ * When does a node not have a typed value? */
+ Q_ASSERT(item);
+ return item.sequencedTypedValue();
+}
+
+Item::Iterator::Ptr Atomizer::evaluateSequence(const DynamicContext::Ptr &context) const
+{
+ return makeSequenceMappingIterator<Item>(ConstPtr(this),
+ m_operand->evaluateSequence(context),
+ context);
+}
+
+Item Atomizer::evaluateSingleton(const DynamicContext::Ptr &context) const
+{
+ const Item item(m_operand->evaluateSingleton(context));
+
+ if(!item) /* Empty is allowed, cardinality is considered '?' */
+ return Item();
+
+ const Item::Iterator::Ptr it(mapToSequence(item, context));
+ Q_ASSERT_X(it, Q_FUNC_INFO, "A valid QAbstractXmlForwardIterator must always be returned.");
+
+ Item result(it->next());
+ Q_ASSERT_X(!it->next(), Q_FUNC_INFO,
+ "evaluateSingleton should never be used if the cardinality is two or more");
+
+ return result;
+}
+
+Expression::Ptr Atomizer::typeCheck(const StaticContext::Ptr &context,
+ const SequenceType::Ptr &reqType)
+{
+ /* Compress -- the earlier the better. */
+ if(BuiltinTypes::xsAnyAtomicType->xdtTypeMatches(m_operand->staticType()->itemType()))
+ return m_operand->typeCheck(context, reqType);
+
+ return SingleContainer::typeCheck(context, reqType);
+}
+
+SequenceType::Ptr Atomizer::staticType() const
+{
+ const SequenceType::Ptr opt(m_operand->staticType());
+ return makeGenericSequenceType(opt->itemType()->atomizedType(),
+ opt->cardinality());
+}
+
+SequenceType::List Atomizer::expectedOperandTypes() const
+{
+ SequenceType::List result;
+ result.append(CommonSequenceTypes::ZeroOrMoreItems);
+ return result;
+}
+
+ExpressionVisitorResult::Ptr Atomizer::accept(const ExpressionVisitor::Ptr &visitor) const
+{
+ return visitor->visit(this);
+}
+
+const SourceLocationReflection *Atomizer::actualReflection() const
+{
+ return m_operand->actualReflection();
+}
+
+QT_END_NAMESPACE
diff --git a/src/xmlpatterns/janitors/qatomizer_p.h b/src/xmlpatterns/janitors/qatomizer_p.h
new file mode 100644
index 0000000..0dc54a6
--- /dev/null
+++ b/src/xmlpatterns/janitors/qatomizer_p.h
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtXmlPatterns module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+
+#ifndef Patternist_Atomizer_H
+#define Patternist_Atomizer_H
+
+#include "qitem_p.h"
+#include "qsinglecontainer_p.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+namespace QPatternist
+{
+
+ /**
+ * @short Performs atomization. Effectively, it is an implementation
+ * of the <tt>fn:data()</tt> function.
+ *
+ * @see <a href="http://www.w3.org/TR/xpath-functions/#func-data">XQuery 1.0 and XPath
+ * 2.0 Functions and Operators, 2.4 fn:data</a>
+ * @see <a href="http://www.w3.org/TR/xpath20/#id-atomization">XML
+ * Path Language (XPath) 2.0, 2.4.2 Atomization</a>
+ * @author Frans Englich <frans.englich@nokia.com>
+ * @ingroup Patternist_expressions
+ */
+ class Atomizer : public SingleContainer
+ {
+ public:
+ Atomizer(const Expression::Ptr &operand);
+
+ virtual Item evaluateSingleton(const DynamicContext::Ptr &) const;
+ virtual Item::Iterator::Ptr evaluateSequence(const DynamicContext::Ptr &) const;
+
+ virtual SequenceType::Ptr staticType() const;
+
+ virtual SequenceType::List expectedOperandTypes() const;
+ virtual const SourceLocationReflection *actualReflection() const;
+
+ /**
+ * Makes an early compression, by returning the result of
+ * the type checked operand, if the operand has the static type
+ * xs:anyAtomicType(no atomization needed).
+ */
+ virtual Expression::Ptr typeCheck(const StaticContext::Ptr &context,
+ const SequenceType::Ptr &reqType);
+
+ inline Item::Iterator::Ptr mapToSequence(const Item &item,
+ const DynamicContext::Ptr &context) const;
+ virtual ExpressionVisitorResult::Ptr accept(const ExpressionVisitor::Ptr &visitor) const;
+
+ private:
+ typedef QExplicitlySharedDataPointer<const Atomizer> ConstPtr;
+ };
+}
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/xmlpatterns/janitors/qcardinalityverifier.cpp b/src/xmlpatterns/janitors/qcardinalityverifier.cpp
new file mode 100644
index 0000000..7b56dbb
--- /dev/null
+++ b/src/xmlpatterns/janitors/qcardinalityverifier.cpp
@@ -0,0 +1,224 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtXmlPatterns module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qcommonsequencetypes_p.h"
+#include "qcommonvalues_p.h"
+#include "qgenericpredicate_p.h"
+#include "qgenericsequencetype_p.h"
+#include "qinsertioniterator_p.h"
+#include "qpatternistlocale_p.h"
+
+#include "qcardinalityverifier_p.h"
+
+QT_BEGIN_NAMESPACE
+
+using namespace QPatternist;
+
+QString CardinalityVerifier::wrongCardinality(const Cardinality &req,
+ const Cardinality &got)
+{
+ return QtXmlPatterns::tr("Required cardinality is %1; got cardinality %2.")
+ .arg(formatType(req), formatType(got));
+}
+
+Expression::Ptr CardinalityVerifier::verifyCardinality(const Expression::Ptr &operand,
+ const Cardinality &requiredCard,
+ const StaticContext::Ptr &context,
+ const ReportContext::ErrorCode code)
+{
+ const Cardinality opCard(operand->staticType()->cardinality());
+
+ if(requiredCard.isMatch(opCard))
+ return operand;
+ else if(requiredCard.canMatch(opCard))
+ return Expression::Ptr(new CardinalityVerifier(operand, requiredCard, code));
+ else if(context->compatModeEnabled() &&
+ !opCard.isEmpty())
+ {
+ return GenericPredicate::createFirstItem(operand);
+ }
+ else
+ {
+ /* Sequences within this cardinality can never match. */
+ context->error(wrongCardinality(requiredCard, opCard), code, operand.data());
+ return operand;
+ }
+}
+
+CardinalityVerifier::CardinalityVerifier(const Expression::Ptr &operand,
+ const Cardinality &card,
+ const ReportContext::ErrorCode code)
+ : SingleContainer(operand),
+ m_reqCard(card),
+ m_allowsMany(operand->staticType()->cardinality().allowsMany()),
+ m_errorCode(code)
+{
+ Q_ASSERT_X(m_reqCard != Cardinality::zeroOrMore(), Q_FUNC_INFO,
+ "It makes no sense to use CardinalityVerifier for cardinality zero-or-more.");
+}
+
+Item::Iterator::Ptr CardinalityVerifier::evaluateSequence(const DynamicContext::Ptr &context) const
+{
+ const Item::Iterator::Ptr it(m_operand->evaluateSequence(context));
+ const Item next(it->next());
+
+ if(next)
+ {
+ const Item next2(it->next());
+
+ if(next2)
+ {
+ if(m_reqCard.allowsMany())
+ {
+ Item::List start;
+ start.append(next);
+ start.append(next2);
+
+ return Item::Iterator::Ptr(new InsertionIterator(it, 1, makeListIterator(start)));
+ }
+ else
+ {
+ context->error(wrongCardinality(m_reqCard, Cardinality::twoOrMore()), m_errorCode, this);
+ return CommonValues::emptyIterator;
+ }
+ }
+ else
+ {
+ /* We might be instantiated for the empty sequence. */
+ if(m_reqCard.isEmpty())
+ {
+ context->error(wrongCardinality(m_reqCard, Cardinality::twoOrMore()), m_errorCode, this);
+ return CommonValues::emptyIterator;
+ }
+ else
+ return makeSingletonIterator(next);
+ }
+ }
+ else
+ {
+ if(m_reqCard.allowsEmpty())
+ return CommonValues::emptyIterator;
+ else
+ {
+ context->error(wrongCardinality(m_reqCard, Cardinality::twoOrMore()), m_errorCode, this);
+ return CommonValues::emptyIterator;
+ }
+ }
+}
+
+Item CardinalityVerifier::evaluateSingleton(const DynamicContext::Ptr &context) const
+{
+ if(m_allowsMany)
+ {
+ const Item::Iterator::Ptr it(m_operand->evaluateSequence(context));
+ const Item item(it->next());
+
+ if(item)
+ {
+ if(it->next())
+ {
+ context->error(wrongCardinality(m_reqCard, Cardinality::twoOrMore()),
+ m_errorCode, this);
+ return Item();
+ }
+ else
+ return item;
+ }
+ else if(m_reqCard.allowsEmpty())
+ return Item();
+ else
+ {
+ context->error(wrongCardinality(m_reqCard), m_errorCode, this);
+ return Item();
+ }
+ }
+ else
+ {
+ const Item item(m_operand->evaluateSingleton(context));
+
+ if(item)
+ return item;
+ else if(m_reqCard.allowsEmpty())
+ return Item();
+ else
+ {
+ context->error(wrongCardinality(m_reqCard), m_errorCode, this);
+ return Item();
+ }
+ }
+}
+
+const SourceLocationReflection *CardinalityVerifier::actualReflection() const
+{
+ return m_operand->actualReflection();
+}
+
+Expression::Ptr CardinalityVerifier::compress(const StaticContext::Ptr &context)
+{
+ if(m_reqCard.isMatch(m_operand->staticType()->cardinality()))
+ return m_operand->compress(context);
+ else
+ return SingleContainer::compress(context);
+}
+
+SequenceType::List CardinalityVerifier::expectedOperandTypes() const
+{
+ SequenceType::List result;
+ result.append(CommonSequenceTypes::ZeroOrMoreItems);
+ return result;
+}
+
+SequenceType::Ptr CardinalityVerifier::staticType() const
+{
+ return makeGenericSequenceType(m_operand->staticType()->itemType(), m_reqCard);
+}
+
+ExpressionVisitorResult::Ptr CardinalityVerifier::accept(const ExpressionVisitor::Ptr &visitor) const
+{
+ return visitor->visit(this);
+}
+
+Expression::ID CardinalityVerifier::id() const
+{
+ return IDCardinalityVerifier;
+}
+
+QT_END_NAMESPACE
diff --git a/src/xmlpatterns/janitors/qcardinalityverifier_p.h b/src/xmlpatterns/janitors/qcardinalityverifier_p.h
new file mode 100644
index 0000000..b5e7342
--- /dev/null
+++ b/src/xmlpatterns/janitors/qcardinalityverifier_p.h
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtXmlPatterns module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+
+#ifndef Patternist_CardinalityVerifier_H
+#define Patternist_CardinalityVerifier_H
+
+#include "qsinglecontainer_p.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+namespace QPatternist
+{
+
+ /**
+ * @short Verifies that the sequence an Expression evaluates to conforms to a Cardinality.
+ *
+ * @see <a href="http://www.w3.org/TR/xpath-functions/#cardinality-funcs">XQuery 1.0 and
+ * XPath 2.0 Functions and Operators, 15.2 Functions That Test the Cardinality of Sequences</a>
+ * @author Frans Englich <frans.englich@nokia.com>
+ * @ingroup Patternist_expressions
+ */
+ class CardinalityVerifier : public SingleContainer
+ {
+ public:
+ CardinalityVerifier(const Expression::Ptr &operand,
+ const Cardinality &card,
+ const ReportContext::ErrorCode code);
+
+ virtual Item::Iterator::Ptr evaluateSequence(const DynamicContext::Ptr &context) const;
+ virtual Item evaluateSingleton(const DynamicContext::Ptr &) const;
+
+ virtual SequenceType::List expectedOperandTypes() const;
+ virtual SequenceType::Ptr staticType() const;
+
+ virtual ExpressionVisitorResult::Ptr accept(const ExpressionVisitor::Ptr &visitor) const;
+
+ /**
+ * If the static cardinality of the operand is within the required cardinality,
+ * the operand is returned as is, since results will always be valid and hence
+ * is not a CardinalityVerifier necessary.
+ */
+ virtual Expression::Ptr compress(const StaticContext::Ptr &context);
+
+ /**
+ * A utility function for determining whether the static type of an Expression matches
+ * a cardinality. More specifically, this function performs the cardinality verification
+ * part of the Function Conversion Rules.
+ *
+ * @todo Mention the rewrite and when exactly an error is issued via @p context
+ */
+ static Expression::Ptr
+ verifyCardinality(const Expression::Ptr &operand,
+ const Cardinality &card,
+ const StaticContext::Ptr &context,
+ const ReportContext::ErrorCode code = ReportContext::XPTY0004);
+
+ virtual const SourceLocationReflection *actualReflection() const;
+
+ ID id() const;
+ private:
+ /**
+ * Centralizes a message string in order to increase consistency and
+ * reduce work for translators.
+ */
+ static inline QString wrongCardinality(const Cardinality &req,
+ const Cardinality &got = Cardinality::empty());
+
+ const Cardinality m_reqCard;
+ const bool m_allowsMany;
+ const ReportContext::ErrorCode m_errorCode;
+ };
+}
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/xmlpatterns/janitors/qebvextractor.cpp b/src/xmlpatterns/janitors/qebvextractor.cpp
new file mode 100644
index 0000000..df06642
--- /dev/null
+++ b/src/xmlpatterns/janitors/qebvextractor.cpp
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtXmlPatterns module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qboolean_p.h"
+#include "qbuiltintypes_p.h"
+#include "qcommonsequencetypes_p.h"
+#include "qgenericsequencetype_p.h"
+
+#include "qebvextractor_p.h"
+
+QT_BEGIN_NAMESPACE
+
+using namespace QPatternist;
+
+EBVExtractor::EBVExtractor(const Expression::Ptr &operand) : SingleContainer(operand)
+{
+}
+
+bool EBVExtractor::evaluateEBV(const DynamicContext::Ptr &context) const
+{
+ return m_operand->evaluateEBV(context);
+}
+
+Expression::Ptr EBVExtractor::typeCheck(const StaticContext::Ptr &context,
+ const SequenceType::Ptr &reqType)
+{
+ return typeCheck<SingleContainer>(context, reqType, this);
+}
+
+SequenceType::Ptr EBVExtractor::staticType() const
+{
+ return makeGenericSequenceType(BuiltinTypes::xsBoolean, Cardinality::exactlyOne());
+}
+
+SequenceType::List EBVExtractor::expectedOperandTypes() const
+{
+ SequenceType::List result;
+ result.append(CommonSequenceTypes::ZeroOrMoreItems);
+ return result;
+}
+
+const SourceLocationReflection *EBVExtractor::actualReflection() const
+{
+ return m_operand->actualReflection();
+}
+
+ExpressionVisitorResult::Ptr EBVExtractor::accept(const ExpressionVisitor::Ptr &visitor) const
+{
+ return visitor->visit(this);
+}
+
+QT_END_NAMESPACE
diff --git a/src/xmlpatterns/janitors/qebvextractor_p.h b/src/xmlpatterns/janitors/qebvextractor_p.h
new file mode 100644
index 0000000..22d3d7a
--- /dev/null
+++ b/src/xmlpatterns/janitors/qebvextractor_p.h
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtXmlPatterns module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+
+#ifndef Patternist_EBVExtractor_H
+#define Patternist_EBVExtractor_H
+
+#include "qsinglecontainer_p.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+namespace QPatternist
+{
+ /**
+ * @short Calculates the Effective Boolean Value of its operand.
+ *
+ * EBVExtractor performs functionality wise the same as @c fn:boolean(),
+ * but does it without the dependencies which FunctionCall requires.
+ *
+ * There is code-duplication going on with BooleanFN.
+ *
+ * @see BooleanFN
+ * @author Frans Englich <frans.englich@nokia.com>
+ * @ingroup Patternist_expressions
+ */
+ class EBVExtractor : public SingleContainer
+ {
+ public:
+ EBVExtractor(const Expression::Ptr &operand);
+ virtual bool evaluateEBV(const DynamicContext::Ptr &context) const;
+ virtual SequenceType::List expectedOperandTypes() const;
+ virtual const SourceLocationReflection *actualReflection() const;
+ virtual Expression::Ptr typeCheck(const StaticContext::Ptr &context,
+ const SequenceType::Ptr &reqType);
+ virtual ExpressionVisitorResult::Ptr accept(const ExpressionVisitor::Ptr &visitor) const;
+
+ /**
+ * @short Returns always @c xs:boolean.
+ */
+ virtual SequenceType::Ptr staticType() const;
+
+ template<typename TSubClass, typename ThisType>
+ static Expression::Ptr typeCheck(const StaticContext::Ptr &context,
+ const SequenceType::Ptr &reqType,
+ ThisType *const caller)
+ {
+ if(*CommonSequenceTypes::EBV->itemType() == *reqType->itemType())
+ return caller->operands().first()->typeCheck(context, reqType);
+ else
+ return caller->TSubClass::typeCheck(context, reqType);
+ }
+
+ };
+}
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/xmlpatterns/janitors/qitemverifier.cpp b/src/xmlpatterns/janitors/qitemverifier.cpp
new file mode 100644
index 0000000..7c7f555
--- /dev/null
+++ b/src/xmlpatterns/janitors/qitemverifier.cpp
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtXmlPatterns module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qcommonsequencetypes_p.h"
+#include "qgenericsequencetype_p.h"
+#include "qitemmappingiterator_p.h"
+#include "qpatternistlocale_p.h"
+
+#include "qitemverifier_p.h"
+
+QT_BEGIN_NAMESPACE
+
+using namespace QPatternist;
+
+ItemVerifier::ItemVerifier(const Expression::Ptr &operand,
+ const ItemType::Ptr &reqType,
+ const ReportContext::ErrorCode errorCode) : SingleContainer(operand),
+ m_reqType(reqType),
+ m_errorCode(errorCode)
+{
+ Q_ASSERT(reqType);
+}
+
+void ItemVerifier::verifyItem(const Item &item, const DynamicContext::Ptr &context) const
+{
+ if(m_reqType->itemMatches(item))
+ return;
+
+ context->error(QtXmlPatterns::tr("The item %1 did not match the required type %2.")
+ .arg(formatData(item.stringValue()),
+ formatType(context->namePool(), m_reqType)),
+ m_errorCode,
+ this);
+}
+
+const SourceLocationReflection *ItemVerifier::actualReflection() const
+{
+ return m_operand->actualReflection();
+}
+
+Item ItemVerifier::evaluateSingleton(const DynamicContext::Ptr &context) const
+{
+ const Item item(m_operand->evaluateSingleton(context));
+
+ if(item)
+ {
+ verifyItem(item, context);
+ return item;
+ }
+ else
+ return Item();
+}
+
+Item ItemVerifier::mapToItem(const Item &item, const DynamicContext::Ptr &context) const
+{
+ verifyItem(item, context);
+ return item;
+}
+
+Item::Iterator::Ptr ItemVerifier::evaluateSequence(const DynamicContext::Ptr &context) const
+{
+ return makeItemMappingIterator<Item>(ConstPtr(this),
+ m_operand->evaluateSequence(context),
+ context);
+}
+
+SequenceType::Ptr ItemVerifier::staticType() const
+{
+ return makeGenericSequenceType(m_reqType, m_operand->staticType()->cardinality());
+}
+
+SequenceType::List ItemVerifier::expectedOperandTypes() const
+{
+ SequenceType::List result;
+ result.append(CommonSequenceTypes::ZeroOrMoreItems);
+ return result;
+}
+
+ExpressionVisitorResult::Ptr ItemVerifier::accept(const ExpressionVisitor::Ptr &visitor) const
+{
+ return visitor->visit(this);
+}
+
+QT_END_NAMESPACE
diff --git a/src/xmlpatterns/janitors/qitemverifier_p.h b/src/xmlpatterns/janitors/qitemverifier_p.h
new file mode 100644
index 0000000..0500425
--- /dev/null
+++ b/src/xmlpatterns/janitors/qitemverifier_p.h
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtXmlPatterns module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+
+#ifndef Patternist_ItemVerifier_H
+#define Patternist_ItemVerifier_H
+
+#include "qsinglecontainer_p.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+namespace QPatternist
+{
+
+ /**
+ * @short Verifies that the items in a sequence an Expression evaluates
+ * is of a certain ItemType.
+ *
+ * @author Frans Englich <frans.englich@nokia.com>
+ * @ingroup Patternist_expressions
+ */
+ class ItemVerifier : public SingleContainer
+ {
+ public:
+
+ ItemVerifier(const Expression::Ptr &operand,
+ const ItemType::Ptr &reqType,
+ const ReportContext::ErrorCode errorCode);
+
+ virtual Item evaluateSingleton(const DynamicContext::Ptr &) const;
+ virtual Item::Iterator::Ptr evaluateSequence(const DynamicContext::Ptr &) const;
+
+ virtual SequenceType::List expectedOperandTypes() const;
+ virtual SequenceType::Ptr staticType() const;
+
+ inline Item mapToItem(const Item &, const DynamicContext::Ptr &) const;
+ virtual ExpressionVisitorResult::Ptr accept(const ExpressionVisitor::Ptr &visitor) const;
+ virtual const SourceLocationReflection *actualReflection() const;
+
+ private:
+ typedef QExplicitlySharedDataPointer<const ItemVerifier> ConstPtr;
+ inline void verifyItem(const Item &item,
+ const DynamicContext::Ptr &context) const;
+
+ const ItemType::Ptr m_reqType;
+ const ReportContext::ErrorCode m_errorCode;
+ };
+}
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/xmlpatterns/janitors/quntypedatomicconverter.cpp b/src/xmlpatterns/janitors/quntypedatomicconverter.cpp
new file mode 100644
index 0000000..4143315
--- /dev/null
+++ b/src/xmlpatterns/janitors/quntypedatomicconverter.cpp
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtXmlPatterns module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qitem_p.h"
+#include "qcommonsequencetypes_p.h"
+#include "qgenericsequencetype_p.h"
+#include "qitemmappingiterator_p.h"
+
+#include "quntypedatomicconverter_p.h"
+
+QT_BEGIN_NAMESPACE
+
+using namespace QPatternist;
+
+UntypedAtomicConverter::UntypedAtomicConverter(const Expression::Ptr &operand,
+ const ItemType::Ptr &reqType,
+ const ReportContext::ErrorCode code) : SingleContainer(operand)
+ , CastingPlatform<UntypedAtomicConverter, true>(code)
+ , m_reqType(reqType)
+{
+ Q_ASSERT(reqType);
+}
+
+Item::Iterator::Ptr UntypedAtomicConverter::evaluateSequence(const DynamicContext::Ptr &context) const
+{
+ return makeItemMappingIterator<Item>(ConstPtr(this),
+ m_operand->evaluateSequence(context),
+ context);
+}
+
+Item UntypedAtomicConverter::evaluateSingleton(const DynamicContext::Ptr &context) const
+{
+ const Item item(m_operand->evaluateSingleton(context));
+
+ if(item)
+ return cast(item, context);
+ else /* Empty is allowed. UntypedAtomicConverter doesn't care about cardinality. */
+ return Item();
+}
+
+Expression::Ptr UntypedAtomicConverter::typeCheck(const StaticContext::Ptr &context,
+ const SequenceType::Ptr &reqType)
+{
+ const Expression::Ptr me(SingleContainer::typeCheck(context, reqType));
+
+ /* Let the CastingPlatform look up its AtomicCaster. */
+ prepareCasting(context, m_operand->staticType()->itemType());
+
+ return me;
+}
+
+SequenceType::List UntypedAtomicConverter::expectedOperandTypes() const
+{
+ SequenceType::List result;
+ result.append(CommonSequenceTypes::ZeroOrMoreAtomicTypes);
+ return result;
+}
+
+SequenceType::Ptr UntypedAtomicConverter::staticType() const
+{
+ return makeGenericSequenceType(m_reqType,
+ m_operand->staticType()->cardinality());
+}
+
+ExpressionVisitorResult::Ptr UntypedAtomicConverter::accept(const ExpressionVisitor::Ptr &visitor) const
+{
+ return visitor->visit(this);
+}
+
+const SourceLocationReflection *UntypedAtomicConverter::actualReflection() const
+{
+ return m_operand.data();
+}
+
+QT_END_NAMESPACE
diff --git a/src/xmlpatterns/janitors/quntypedatomicconverter_p.h b/src/xmlpatterns/janitors/quntypedatomicconverter_p.h
new file mode 100644
index 0000000..016718a
--- /dev/null
+++ b/src/xmlpatterns/janitors/quntypedatomicconverter_p.h
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtXmlPatterns module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+
+#ifndef Patternist_UntypedAtomicConverter_H
+#define Patternist_UntypedAtomicConverter_H
+
+#include "qitem_p.h"
+#include "qsinglecontainer_p.h"
+#include "qcastingplatform_p.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+namespace QPatternist
+{
+ /**
+ * @short Casts every item in a sequence obtained from
+ * evaluating an Expression, to a requested atomic type.
+ *
+ * The atomic values it casts from are instances of xs:untypedAtomic(hence
+ * the name). Typically, the items are from an Atomizer. UntypedAtomicConverter
+ * implements the automatic conversion which typically is activated when XPath
+ * is handling untyped data.
+ *
+ * @see <a href="http://www.w3.org/TR/xpath20/#id-function-calls">XML Path
+ * Language (XPath) 2.0, 3.1.5 Function Calls, in particular the
+ * Function Conversion Rules</a>
+ * @author Frans Englich <frans.englich@nokia.com>
+ * @ingroup Patternist_expressions
+ */
+ class UntypedAtomicConverter : public SingleContainer,
+ public CastingPlatform<UntypedAtomicConverter, true>
+ {
+ public:
+ UntypedAtomicConverter(const Expression::Ptr &operand,
+ const ItemType::Ptr &reqType,
+ const ReportContext::ErrorCode code = ReportContext::FORG0001);
+
+ virtual Item evaluateSingleton(const DynamicContext::Ptr &) const;
+ virtual Item::Iterator::Ptr evaluateSequence(const DynamicContext::Ptr &) const;
+
+ virtual SequenceType::Ptr staticType() const;
+ virtual SequenceType::List expectedOperandTypes() const;
+
+ virtual ExpressionVisitorResult::Ptr accept(const ExpressionVisitor::Ptr &visitor) const;
+
+ /**
+ * Overridden to call CastingPlatform::typeCheck()
+ */
+ virtual Expression::Ptr typeCheck(const StaticContext::Ptr &context,
+ const SequenceType::Ptr &reqType);
+
+ inline Item mapToItem(const Item &item,
+ const DynamicContext::Ptr &context) const;
+
+ inline ItemType::Ptr targetType() const
+ {
+ return m_reqType;
+ }
+
+ virtual const SourceLocationReflection *actualReflection() const;
+
+ private:
+ typedef QExplicitlySharedDataPointer<const UntypedAtomicConverter> ConstPtr;
+ const ItemType::Ptr m_reqType;
+ };
+
+ Item UntypedAtomicConverter::mapToItem(const Item &item, const DynamicContext::Ptr &context) const
+ {
+ return cast(item, context);
+ }
+}
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif