Item AttributeNameValidator::evaluateSingleton(const DynamicContext::Ptr &context) const { const Item name(m_operand->evaluateSingleton(context)); const QXmlName qName(name.as<QNameValue>()->qName()); if(qName.namespaceURI() == StandardNamespaces::xmlns) { context->error(QtXmlPatterns::tr("The namespace URI in the name for a " "computed attribute cannot be %1.") .arg(formatURI(CommonNamespaces::XMLNS)), ReportContext::XQDY0044, this); return Item(); /* Silence warning. */ } else if(qName.namespaceURI() == StandardNamespaces::empty && qName.localName() == StandardLocalNames::xmlns) { context->error(QtXmlPatterns::tr("The name for a computed attribute " "cannot have the namespace URI %1 " "with the local name %2.") .arg(formatURI(CommonNamespaces::XMLNS)) .arg(formatKeyword("xmlns")), ReportContext::XQDY0044, this); return Item(); /* Silence warning. */ } else if(!qName.hasPrefix() && qName.hasNamespace()) { return Item(QNameValue::fromValue(context->namePool(), QXmlName(qName.namespaceURI(), qName.localName(), StandardPrefixes::ns0))); } else return name; }
QString NamePool::displayName(const QXmlName qName) const { QReadLocker l(mutableLock()); if(qName.hasNamespace()) { const QString &p = displayPrefix(qName.namespaceURI()); if(p.isEmpty()) return QLatin1Char('{') + m_namespaces.at(qName.namespaceURI()) + QLatin1Char('}') + toLexical(qName); else return p + QLatin1Char(':') + m_localNames.at(qName.localName()); } else return m_localNames.at(qName.localName()); }
QString NamePool::displayName(const QXmlName qName) const { QReadLocker l(&lock); if(qName.hasNamespace()) { if(qName.namespaceURI() == StandardNamespaces::InternalXSLT) return QLatin1Char('#') + m_localNames.at(qName.localName()); const QString &p = displayPrefix(qName.namespaceURI()); if(p.isEmpty()) return QLatin1Char('{') + m_namespaces.at(qName.namespaceURI()) + QLatin1Char('}') + toLexical(qName); else return p + QLatin1Char(':') + m_localNames.at(qName.localName()); } else return m_localNames.at(qName.localName()); }
QString NamePool::toClarkName(const QXmlName &name) const { if(name.isNull()) return QLatin1String("QXmlName(null)"); else { if(name.hasNamespace()) { const QString ns(stringForNamespace(name.namespaceURI())); const QString p(stringForPrefix(name.prefix())); const QString l(stringForLocalName(name.localName())); return QChar::fromLatin1('{') + ns + QChar::fromLatin1('}') + (p.isEmpty() ? l : p + QChar::fromLatin1(':') + l); } else return stringForLocalName(name.localName()); } }