Expression::Ptr ElementConstructor::typeCheck(const StaticContext::Ptr &context, const SequenceType::Ptr &reqType) { /* What does this code do? When type checking our children, our namespace * bindings, which are also children of the form of NamespaceConstructor * instances, must be statically in-scope for them, so find them and * shuffle their bindings into the StaticContext. */ m_staticBaseURI = context->baseURI(); /* Namespace declarations changes the in-scope bindings, so let's * first lookup our child NamespaceConstructors. */ const ID operandID = m_operand2->id(); NamespaceResolver::Bindings overrides; if(operandID == IDExpressionSequence) { const Expression::List operands(m_operand2->operands()); const int len = operands.count(); for(int i = 0; i < len; ++i) { if(operands.at(i)->is(IDNamespaceConstructor)) { const QXmlName &nb = operands.at(i)->as<NamespaceConstructor>()->namespaceBinding(); overrides.insert(nb.prefix(), nb.namespaceURI()); } } } const NamespaceResolver::Ptr newResolver(new DelegatingNamespaceResolver(context->namespaceBindings(), overrides)); const StaticContext::Ptr augmented(new StaticNamespaceContext(newResolver, context)); return PairContainer::typeCheck(augmented, reqType); }
ParserContext::ParserContext(const StaticContext::Ptr &context, const QXmlQuery::QueryLanguage lang, Tokenizer *const tokener) : staticContext(context) , tokenizer(tokener) , languageAccent(lang) , nodeTestSource(BuiltinTypes::element) , moduleNamespace(StandardNamespaces::empty) , isPreviousEnclosedExpr(false) , elementConstructorDepth(0) , hasSecondPrologPart(false) , preserveNamespacesMode(true) , inheritNamespacesMode(true) , isParsingPattern(false) , currentImportPrecedence(1) , m_evaluationCacheSlot(-1) , m_expressionSlot(0) , m_positionSlot(-1) , m_globalVariableSlot(-1) , m_currentTemplateID(InitialTemplateID) { resolvers.push(context->namespaceBindings()); Q_ASSERT(tokenizer); Q_ASSERT(context); m_isParsingWithParam.push(false); isBackwardsCompat.push(false); }
Expression::Ptr ElementConstructor::typeCheck(const StaticContext::Ptr &context, const SequenceType::Ptr &reqType) { m_staticBaseURI = context->baseURI(); /* Namespace declarations changes the in-scope bindings, so let's * first lookup our child NamespaceConstructors. */ const ID operandID = m_operand2->id(); NamespaceResolver::Bindings overrides; if(operandID == IDExpressionSequence) { const Expression::List operands(m_operand2->operands()); const int len = operands.count(); for(int i = 0; i < len; ++i) { if(operands.at(i)->is(IDNamespaceConstructor)) { const QXmlName &nb = operands.at(i)->as<NamespaceConstructor>()->namespaceBinding(); overrides.insert(nb.prefix(), nb.namespaceURI()); } } } const NamespaceResolver::Ptr newResolver(new DelegatingNamespaceResolver(context->namespaceBindings(), overrides)); const StaticContext::Ptr augmented(new StaticNamespaceContext(newResolver, context)); return PairContainer::typeCheck(augmented, reqType); }
Expression::Ptr StaticNamespacesContainer::typeCheck(const StaticContext::Ptr &context, const SequenceType::Ptr &reqType) { m_resolver = NamespaceResolver::Ptr(context->namespaceBindings()); Q_ASSERT(m_resolver); return FunctionCall::typeCheck(context, reqType); }
Expression::Ptr CastAs::castToQName(const StaticContext::Ptr &context) const { /* Apply the whitespace facet by calling trimmed(). */ /* We can assume m_operand is an Expression because this is a requirement * for casting to xs:QName. */ const QString lexQName(m_operand->as<Literal>()->item().as<AtomicValue>()->stringValue().trimmed()); const QXmlName expName(QNameConstructor::expandQName<StaticContext::Ptr, ReportContext::FORG0001, ReportContext::FONS0004>(lexQName, context, context->namespaceBindings(), this)); return wrapLiteral(toItem(QNameValue::fromValue(context->namePool(), expName)), context, this); }
QXmlName::NamespaceCode QNameConstructor::namespaceForPrefix(const QXmlName::PrefixCode prefix, const StaticContext::Ptr &context, const SourceLocationReflection *const r) { Q_ASSERT(context); const QXmlName::NamespaceCode ns(context->namespaceBindings()->lookupNamespaceURI(prefix)); if(ns == NamespaceResolver::NoBinding) { context->error(QtXmlPatterns::tr("No namespace binding exists for the prefix %1") .arg(formatKeyword(context->namePool()->stringForPrefix(prefix))), ReportContext::XPST0081, r); return NamespaceResolver::NoBinding; } else return ns; }