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

Ensures the lexical space of the string value of the Item returned from its child Expression is an NCName. Also possibly changes the name by generating a prefix if one is needed. More...

#include <qattributenamevalidator_p.h>

Inheritance diagram for QPatternist::AttributeNameValidator:
QPatternist::SingleContainer QPatternist::Expression QSharedData QPatternist::CppCastingHelper< Expression > QPatternist::SourceLocationReflection

Public Functions

virtual ExpressionVisitorResult::Ptr accept (const ExpressionVisitor::Ptr &visitor) const
 
 AttributeNameValidator (const Expression::Ptr &source)
 
virtual Item evaluateSingleton (const DynamicContext::Ptr &) const
 
virtual SequenceType::List expectedOperandTypes () const
 
virtual SequenceType::Ptr staticType () const
 
- Public Functions inherited from QPatternist::SingleContainer
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 void evaluateToSequenceReceiver (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
 
virtual Properties properties () 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::SingleContainer
 SingleContainer (const Expression::Ptr &operand)
 
- 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::SingleContainer
Expression::Ptr m_operand
 

Detailed Description

Ensures the lexical space of the string value of the Item returned from its child Expression is an NCName. Also possibly changes the name by generating a prefix if one is needed.

Note
It doesn't actually construct an xs:NCName. It only ensures the lexical space is an NCName. The atomic value can be of any string type, such as xs:untypedAtomic of xs:string.
Author
Frans Englich frans.nosp@m..eng.nosp@m.lich@.nosp@m.noki.nosp@m.a.com

Definition at line 75 of file qattributenamevalidator_p.h.

Constructors and Destructors

◆ AttributeNameValidator()

AttributeNameValidator::AttributeNameValidator ( const Expression::Ptr source)

Definition at line 55 of file qattributenamevalidator.cpp.

55  : SingleContainer(source)
56 {
57 }
SingleContainer(const Expression::Ptr &operand)

Functions

◆ accept()

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

Implements QPatternist::Expression.

Definition at line 104 of file qattributenamevalidator.cpp.

105 {
106  return visitor->visit(this);
107 }

◆ evaluateSingleton()

Item AttributeNameValidator::evaluateSingleton ( const DynamicContext::Ptr context) const
virtual

Reimplemented from QPatternist::Expression.

Definition at line 59 of file qattributenamevalidator.cpp.

60 {
61  const Item name(m_operand->evaluateSingleton(context));
62  const QXmlName qName(name.as<QNameValue>()->qName());
63 
64  if(qName.namespaceURI() == StandardNamespaces::xmlns)
65  {
66  context->error(QtXmlPatterns::tr("The namespace URI in the name for a "
67  "computed attribute cannot be %1.")
70  return Item(); /* Silence warning. */
71  }
72  else if(qName.namespaceURI() == StandardNamespaces::empty &&
73  qName.localName() == StandardLocalNames::xmlns)
74  {
75  context->error(QtXmlPatterns::tr("The name for a computed attribute "
76  "cannot have the namespace URI %1 "
77  "with the local name %2.")
79  .arg(formatKeyword("xmlns")),
81  return Item(); /* Silence warning. */
82  }
83  else if(!qName.hasPrefix() && qName.hasNamespace())
84  {
85  return Item(QNameValue::fromValue(context->namePool(),
86  QXmlName(qName.namespaceURI(), qName.localName(), StandardPrefixes::ns0)));
87  }
88  else
89  return name;
90 }
virtual NamePool::Ptr namePool() const =0
QString formatKeyword(const QString &keyword)
QXmlName qName() const
Definition: qqnamevalue_p.h:96
void error(const QString &message, const ReportContext::ErrorCode errorCode, const QSourceLocation &sourceLocation)
static QNameValue::Ptr fromValue(const NamePool::Ptr &np, const QXmlName name)
Definition: qqnamevalue.cpp:59
const char * name
const QLatin1String XMLNS("http://www.w3.org/2000/xmlns/")
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
Implements the value instance of the xs:QName type.
Definition: qqnamevalue_p.h:73
static QString formatURI(const NamePool::Ptr &np, const QXmlName::NamespaceCode &uri)
Formats uri, that&#39;s considered to be a URI, for display.
Definition: qanyuri_p.h:202
virtual Item evaluateSingleton(const DynamicContext::Ptr &context) const

◆ expectedOperandTypes()

SequenceType::List AttributeNameValidator::expectedOperandTypes ( ) const
virtual

Returns a list of Sequence Types, describing the type of each of the expression's operands. Hence, this function has a relationship to the operands() function:

- The lengths of the lists returned by expectedOperandTypes()
and operands() should always be equal in length, since one
cannot describe the type of a non-existent operand(and all
operands must have type information).
- A significant difference between the two functions is that while
the type of objects in the list returned by operands() may vary
between compilations/static context, simply because the particular
Expression is part of different XPath expressions, the
types in the list returned by expectedOperandTypes is always the same
since the function/operator signature never changes.

This function should not be confused with staticType(), which returns the static type of the expression itself, not its operands. The function call is an expression where this is clear: the type of the return value is not the same as the arguments' types. The static type of the operands supplied to the expression can be determined via the staticType() function of the instances returned by operands().

If the expression has no operands, an empty list should be returned.

Implements QPatternist::Expression.

Definition at line 97 of file qattributenamevalidator.cpp.

98 {
99  SequenceType::List result;
101  return result;
102 }
static const SequenceType::Ptr ExactlyOneQName
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

◆ staticType()

SequenceType::Ptr AttributeNameValidator::staticType ( ) const
virtual
Returns
the static type of its operand. This is returned as opposed CommonSequenceTypes::ExactlyOneQName, since the operand might return a subtype of xs:QName.

Implements QPatternist::Expression.

Definition at line 92 of file qattributenamevalidator.cpp.

93 {
94  return m_operand->staticType();
95 }
virtual SequenceType::Ptr staticType() const =0

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