1 /****************************************************************************
3 ** Copyright (C) 2012 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 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
44 * @short This file is included by BuiltintNodeType.h.
45 * If you need includes in this file, put them in BuiltintNodeType.h, outside of the namespace.
48 template <const QXmlNodeModelIndex::NodeKind kind>
49 BuiltinNodeType<kind>::BuiltinNodeType()
53 template <const QXmlNodeModelIndex::NodeKind kind>
54 bool BuiltinNodeType<kind>::xdtTypeMatches(const ItemType::Ptr &other) const
56 if(!other->isNodeType())
59 return *static_cast<const BuiltinNodeType *>(other.data()) == *this
61 : xdtTypeMatches(other->xdtSuperType());
64 template <const QXmlNodeModelIndex::NodeKind kind>
65 bool BuiltinNodeType<kind>::itemMatches(const Item &item) const
69 return item.isNode() &&
70 item.asNode().kind() == kind;
73 template <const QXmlNodeModelIndex::NodeKind kind>
74 ItemType::Ptr BuiltinNodeType<kind>::atomizedType() const
78 /* Fallthrough all these. */
79 case QXmlNodeModelIndex::Attribute:
80 case QXmlNodeModelIndex::Document:
81 case QXmlNodeModelIndex::Element:
82 case QXmlNodeModelIndex::Text:
83 return BuiltinTypes::xsUntypedAtomic;
84 case QXmlNodeModelIndex::ProcessingInstruction:
86 case QXmlNodeModelIndex::Comment:
87 return BuiltinTypes::xsString;
90 Q_ASSERT_X(false, Q_FUNC_INFO,
91 "Encountered invalid XPath Data Model node type.");
92 return BuiltinTypes::xsUntypedAtomic;
97 template <const QXmlNodeModelIndex::NodeKind kind>
98 QString BuiltinNodeType<kind>::displayName(const NamePool::Ptr &) const
102 case QXmlNodeModelIndex::Element:
103 return QLatin1String("element()");
104 case QXmlNodeModelIndex::Document:
105 return QLatin1String("document()");
106 case QXmlNodeModelIndex::Attribute:
107 return QLatin1String("attribute()");
108 case QXmlNodeModelIndex::Text:
109 return QLatin1String("text()");
110 case QXmlNodeModelIndex::ProcessingInstruction:
111 return QLatin1String("processing-instruction()");
112 case QXmlNodeModelIndex::Comment:
113 return QLatin1String("comment()");
116 Q_ASSERT_X(false, Q_FUNC_INFO,
117 "Encountered invalid XPath Data Model node type.");
123 template <const QXmlNodeModelIndex::NodeKind kind>
124 ItemType::Ptr BuiltinNodeType<kind>::xdtSuperType() const
126 return BuiltinTypes::node;
129 template <const QXmlNodeModelIndex::NodeKind kind>
130 QXmlNodeModelIndex::NodeKind BuiltinNodeType<kind>::nodeKind() const
135 template <const QXmlNodeModelIndex::NodeKind kind>
136 PatternPriority BuiltinNodeType<kind>::patternPriority() const
138 /* See XSL Transformations (XSLT) Version 2.0, 6.4 Conflict Resolution for
142 case QXmlNodeModelIndex::Text:
144 case QXmlNodeModelIndex::ProcessingInstruction:
146 case QXmlNodeModelIndex::Comment:
147 /* "If the pattern is any other NodeTest, optionally preceded by a
148 * PatternAxis, then the priority is 0.5."
150 case QXmlNodeModelIndex::Attribute:
152 case QXmlNodeModelIndex::Element:
154 case QXmlNodeModelIndex::Document:
155 /* "If the pattern has the form /, then the priority is -0.5.". */
159 Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown node type");