Item::Iterator::Ptr AxisStep::evaluateSequence(const DynamicContext::Ptr &context) const { /* If we don't have a focus, it's either a bug or our parent isn't a Path * that have advanced the focus iterator. Hence, attempt to advance the focus on our own. */ if(!context->contextItem()) context->focusIterator()->next(); Q_ASSERT(context->contextItem()); const QXmlNodeModelIndex::Iterator::Ptr source(context->contextItem().asNode().iterate(m_axis)); return makeItemMappingIterator<Item>(ConstPtr(this), source, context); }
Item::Iterator::Ptr ApplyTemplate::evaluateSequence(const DynamicContext::Ptr &context) const { const TemplateMode::Ptr templateMode(effectiveMode(context)); const Template::Ptr &templateMatch = findTemplate(context, templateMode); if(templateMatch) return templateMatch->body->evaluateSequence(templateMatch->createContext(this, context, false)); else { /* None of our templates matched. Proceed with a built-in. */ const Item current(context->contextItem()); // TODO it can be an atomic value? const QXmlNodeModelIndex::NodeKind kind(current.asNode().kind()); if(kind == QXmlNodeModelIndex::Element || kind == QXmlNodeModelIndex::Document) { pDebug() << "No template match, using builtin template for element() | document-node()"; const Item::Iterator::Ptr focusIterator(makeItemMappingIterator<Item>(ConstPtr(this), current.asNode().iterate(QXmlNodeModelIndex::AxisChild), context)); const DynamicContext::Ptr focus(context->createFocus()); focus->setFocusIterator(focusIterator); return makeSequenceMappingIterator<Item>(ConstPtr(this), focusIterator, focus); } return CommonValues::emptyIterator; } }
Item AxisStep::evaluateSingleton(const DynamicContext::Ptr &context) const { /* If we don't have a focus, it's either a bug or our parent isn't a Path * that have advanced the focus iterator. Hence, attempt to advance the focus on our own. */ if(!context->contextItem()) context->focusIterator()->next(); Q_ASSERT(context->contextItem()); const QXmlNodeModelIndex::Iterator::Ptr it(context->contextItem().asNode().iterate(m_axis)); QXmlNodeModelIndex next(it->next()); while(!next.isNull()) { const Item candidate(mapToItem(next, context)); if(candidate) return candidate; else next = it->next(); }; return Item(); }
DynamicContext::Ptr CurrentItemStore::createContext(const DynamicContext::Ptr &old) const { return DynamicContext::Ptr(new CurrentItemContext(old->contextItem(), old)); }
Item ContextItem::evaluateSingleton(const DynamicContext::Ptr &context) const { return context->contextItem(); }
Item ParentNodeAxis::evaluateSingleton(const DynamicContext::Ptr &context) const { return context->contextItem().asNode().iterate(QXmlNodeModelIndex::AxisParent)->next(); }
Item UnparsedEntityURIFN::evaluateSingleton(const DynamicContext::Ptr &context) const { checkTargetNode(context->contextItem().asNode(), context, ReportContext::XTDE1370); return toItem(AnyURI::fromValue(QUrl())); }
Item UnparsedEntityPublicIDFN::evaluateSingleton(const DynamicContext::Ptr &context) const { checkTargetNode(context->contextItem().asNode(), context, ReportContext::XTDE1380); return AtomicString::fromValue(QString()); }