Qt 4.8
Public Functions | List of all members
QPatternist::ComputedNamespaceConstructor Class Reference

Constructs a namespace on an element, and naturally only appears as a child of ElementConstructor. More...

#include <qcomputednamespaceconstructor_p.h>

Inheritance diagram for QPatternist::ComputedNamespaceConstructor:
QPatternist::PairContainer QPatternist::Expression QSharedData QPatternist::CppCastingHelper< Expression > QPatternist::SourceLocationReflection

Public Functions

virtual ExpressionVisitorResult::Ptr accept (const ExpressionVisitor::Ptr &visitor) const
 
 ComputedNamespaceConstructor (const Expression::Ptr &prefix, const Expression::Ptr &namespaceURI)
 
virtual void evaluateToSequenceReceiver (const DynamicContext::Ptr &context) const
 
virtual SequenceType::List expectedOperandTypes () const
 
virtual Expression::Properties properties () const
 
virtual SequenceType::Ptr staticType () const
 
- Public Functions inherited from QPatternist::PairContainer
virtual bool compressOperands (const StaticContext::Ptr &)
 
virtual Expression::List operands () const
 
virtual void setOperands (const Expression::List &operands)
 
- Public Functions inherited from QPatternist::Expression
virtual const SourceLocationReflectionactualReflection () const
 Returns this. More...
 
virtual void announceFocusType (const ItemType::Ptr &itemType)
 
virtual Expression::Ptr compress (const StaticContext::Ptr &context)
 
Properties deepProperties () const
 Computes the union of properties for this Expression and all its descending children. More...
 
virtual Properties dependencies () const
 
virtual QString description () const
 
virtual bool evaluateEBV (const DynamicContext::Ptr &context) const
 
virtual Item::Iterator::Ptr evaluateSequence (const DynamicContext::Ptr &context) const
 
virtual Item evaluateSingleton (const DynamicContext::Ptr &context) const
 
virtual ItemType::Ptr expectedContextItemType () const
 
 Expression ()
 
bool has (const Property prop) const
 
bool hasDependency (const Property prop) const
 
virtual ID id () const
 
bool is (const ID id) const
 
bool isEvaluated () const
 
virtual ItemType::Ptr newFocusType () const
 
virtual QList< QExplicitlySharedDataPointer< OptimizationPass > > optimizationPasses () const
 
virtual PatternPriority patternPriority () const
 
const Expression::Ptrrewrite (const Expression::Ptr &to, const StaticContext::Ptr &context) const
 Rewrites this Expression to to, and return to. More...
 
virtual Expression::Ptr typeCheck (const StaticContext::Ptr &context, const SequenceType::Ptr &reqType)
 
virtual ~Expression ()
 
- Public Functions inherited from QSharedData
 QSharedData ()
 Constructs a QSharedData object with a reference count of 0. More...
 
 QSharedData (const QSharedData &)
 Constructs a QSharedData object with reference count 0. More...
 
- Public Functions inherited from QPatternist::CppCastingHelper< Expression >
const TCastTarget * as () const
 
TCastTarget * as ()
 
- Public Functions inherited from QPatternist::SourceLocationReflection
virtual QSourceLocation sourceLocation () const
 
 SourceLocationReflection ()
 
virtual ~SourceLocationReflection ()
 

Additional Inherited Members

- Public Types inherited from QPatternist::Expression
typedef QExplicitlySharedDataPointer< const ExpressionConstPtr
 A smart pointer wrapping const Expression instances. More...
 
enum  ID {
  IDBooleanValue = 1, IDCountFN, IDEmptyFN, IDExistsFN,
  IDExpressionSequence, IDGeneralComparison, IDIfThenClause, IDIgnorableExpression,
  IDIntegerValue, IDPositionFN, IDStringValue, IDValueComparison,
  IDRangeVariableReference, IDContextItem, IDUserFunctionCallsite, IDExpressionVariableReference,
  IDAttributeConstructor, IDUpperCaseFN, IDLowerCaseFN, IDFirstItemPredicate,
  IDEmptySequence, IDReturnOrderBy, IDLetClause, IDForClause,
  IDPath, IDNamespaceConstructor, IDArgumentReference, IDGenericPredicate,
  IDAxisStep, IDFloat, IDCombineNodes, IDUnresolvedVariableReference,
  IDCardinalityVerifier
}
 
typedef QList< Expression::PtrList
 
typedef QFlags< PropertyProperties
 
enum  Property {
  UseContextItem = 1, DisableElimination = 1 << 1, IsEvaluated = 1 << 2, DisableTypingDeduction = 1 << 3,
  EmptynessFollowsChild = 1 << 4, RewriteToEmptyOnEmpty = 1 << 5, RequiresFocus = 1 << 6, AffectsOrderOnly = 1 << 7,
  RequiresContextItem = (1 << 8) | RequiresFocus, CreatesFocusForLast = 1 << 9, LastOperandIsCollation = 1 << 10, DependsOnLocalVariable = (1 << 11) | DisableElimination,
  EvaluationCacheRedundant = (1 << 12), IsNodeConstructor = 1 << 13, RequiresCurrentItem = 1 << 14
}
 
typedef QExplicitlySharedDataPointer< ExpressionPtr
 A smart pointer wrapping mutable Expression instances. More...
 
typedef ::QAbstractXmlForwardIterator< Expression::PtrQAbstractXmlForwardIterator
 
typedef QVector< Expression::PtrVector
 
- Static Public Functions inherited from QPatternist::Expression
static void rewrite (Expression::Ptr &old, const Expression::Ptr &New, const StaticContext::Ptr &context)
 
- Public Variables inherited from QSharedData
QAtomicInt ref
 
- Protected Functions inherited from QPatternist::PairContainer
 PairContainer (const Expression::Ptr &operand1, const Expression::Ptr &operand2)
 
- Protected Functions inherited from QPatternist::Expression
void typeCheckOperands (const StaticContext::Ptr &context)
 
- Protected Functions inherited from QPatternist::CppCastingHelper< Expression >
 CppCastingHelper ()
 
- Protected Variables inherited from QPatternist::PairContainer
Expression::Ptr m_operand1
 
Expression::Ptr m_operand2
 

Detailed Description

Constructs a namespace on an element, and naturally only appears as a child of ElementConstructor.

Author
Frans Englich frans.nosp@m..eng.nosp@m.lich@.nosp@m.noki.nosp@m.a.com
Since
4.5

Definition at line 71 of file qcomputednamespaceconstructor_p.h.

Constructors and Destructors

◆ ComputedNamespaceConstructor()

ComputedNamespaceConstructor::ComputedNamespaceConstructor ( const Expression::Ptr prefix,
const Expression::Ptr namespaceURI 
)

Definition at line 54 of file qcomputednamespaceconstructor.cpp.

55  : PairContainer(prefix, namespaceURI)
56 {
57 }
PairContainer(const Expression::Ptr &operand1, const Expression::Ptr &operand2)

Functions

◆ accept()

ExpressionVisitorResult::Ptr ComputedNamespaceConstructor::accept ( const ExpressionVisitor::Ptr visitor) const
virtual

Implements QPatternist::Expression.

Definition at line 131 of file qcomputednamespaceconstructor.cpp.

132 {
133  return visitor->visit(this);
134 }

◆ evaluateToSequenceReceiver()

void ComputedNamespaceConstructor::evaluateToSequenceReceiver ( const DynamicContext::Ptr context) const
virtual

Evaluates this Expression by sending its output to DynamicContext::outputReceiver().

Reimplemented from QPatternist::Expression.

Definition at line 59 of file qcomputednamespaceconstructor.cpp.

60 {
61  const Item prefixItem(m_operand1->evaluateSingleton(context));
62  const QString prefix(prefixItem ? prefixItem.stringValue() : QString());
63 
64  const Item namespaceItem(m_operand2->evaluateSingleton(context));
65  const QString namespaceURI(namespaceItem ? namespaceItem.stringValue() : QString());
66 
67  if(namespaceURI.isEmpty())
68  {
69  context->error(QtXmlPatterns::tr("In a namespace constructor, the value for a namespace cannot be an empty string."),
71  this);
72  }
73 
74  /* One optimization could be to store a pointer to
75  * the name pool as a member in order to avoid the virtual call(s). */
76  const NamePool::Ptr np(context->namePool());
77 
78  if(!prefix.isEmpty() && !QXmlUtils::isNCName(prefix))
79  {
80  context->error(QtXmlPatterns::tr("The prefix must be a valid %1, which %2 is not.")
82  formatKeyword(prefix)),
84  this);
85  }
86  const QXmlName binding(np->allocateBinding(prefix, namespaceURI));
87 
88  AnyURI::toQUrl<ReportContext::XTDE0905, DynamicContext::Ptr>(namespaceURI,
89  context,
90  this);
91 
92  if(binding.prefix() == StandardPrefixes::xmlns)
93  {
94  context->error(QtXmlPatterns::tr("The prefix %1 cannot be bound.")
95  .arg(formatKeyword(prefix)),
97  this);
98  }
99 
100  if((binding.prefix() == StandardPrefixes::xml && binding.namespaceURI() != StandardNamespaces::xml)
101  ||
102  (binding.prefix() != StandardPrefixes::xml && binding.namespaceURI() == StandardNamespaces::xml))
103  {
104  context->error(QtXmlPatterns::tr("Only the prefix %1 can be bound to %2 and vice versa.")
105  .arg(formatKeyword(prefix), formatKeyword(namespaceURI)),
107  this);
108  }
109 
110  context->outputReceiver()->namespaceBinding(binding);
111 }
virtual NamePool::Ptr namePool() const =0
QString formatKeyword(const QString &keyword)
QString formatType(const NamePool::Ptr &np, const T &type)
Formats ItemType and SequenceType.
The QString class provides a Unicode character string.
Definition: qstring.h:83
void error(const QString &message, const ReportContext::ErrorCode errorCode, const QSourceLocation &sourceLocation)
The QXmlName class represents the name of an XML node, in an efficient, namespace-aware way...
Definition: qxmlname.h:58
Represents an item in the XPath 2.0 Data Model.
Definition: qitem_p.h:182
static const AtomicType::Ptr xsNCName
static bool isNCName(const QStringRef &ncName)
Determines whether c is a valid instance of production [4]NCName in the XML 1.0 Namespaces specificat...
Definition: qxmlutils.cpp:377
virtual Item evaluateSingleton(const DynamicContext::Ptr &context) const

◆ expectedOperandTypes()

SequenceType::List ComputedNamespaceConstructor::expectedOperandTypes ( ) const
virtual
Returns
a list containing one CommonSequenceTypes::ExactlyOneString instance.

Implements QPatternist::Expression.

Definition at line 118 of file qcomputednamespaceconstructor.cpp.

119 {
120  SequenceType::List result;
123  return result;
124 }
static const SequenceType::Ptr ZeroOrOneString
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ properties()

Expression::Properties ComputedNamespaceConstructor::properties ( ) const
virtual
Returns
a bitwise OR'd value of properties, describing the characteristics of the expression. These properties affects how this Expression is treated in for example type checking stages.

The default implementation returns 0. Override and let the function return a different value, if that's of interest.

An important decision when re-implementing properties() is whether to OR in the properties() of ones operands. For instance, if an operand has RequiresFocus set, that flag nost likely applies to the apparent as well, since it depends on its operand.

See also
deepProperties()
Returns
Expression::None, meaning no special properties

Reimplemented from QPatternist::Expression.

Definition at line 126 of file qcomputednamespaceconstructor.cpp.

◆ staticType()

SequenceType::Ptr ComputedNamespaceConstructor::staticType ( ) const
virtual

The static type is exactly one attribute node. It's unclear what affects the static type has, but specifying anything else could lead to complications wrt. node order, XQTY0024. Of course, it's not conceptually correct, since a namespace node isn't an attribute node.

Implements QPatternist::Expression.

Definition at line 113 of file qcomputednamespaceconstructor.cpp.

114 {
116 }
static const SequenceType::Ptr ExactlyOneAttribute

The documentation for this class was generated from the following files: