本文整理汇总了C++中QXmlName::hasPrefix方法的典型用法代码示例。如果您正苦于以下问题:C++ QXmlName::hasPrefix方法的具体用法?C++ QXmlName::hasPrefix怎么用?C++ QXmlName::hasPrefix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QXmlName
的用法示例。
在下文中一共展示了QXmlName::hasPrefix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: evaluateSingleton
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;
}
示例2: normalized
void AccelTreeBuilder<FromDocument>::attribute(const QXmlName &name, const QStringRef &value)
{
/* Attributes adds a namespace binding, so lets synthesize one.
*
* We optimize by checking whether we have a namespace for which a binding would
* be generated. Happens relatively rarely. */
if(name.hasPrefix())
namespaceBinding(QXmlName(name.namespaceURI(), 0, name.prefix()));
m_document->basicData.append(AccelTree::BasicNodeData(currentDepth(), currentParent(), QXmlNodeModelIndex::Attribute, 0, name));
++m_preNumber;
++m_size.top();
m_isPreviousAtomic = false;
if(name.namespaceURI() == StandardNamespaces::xml && name.localName() == StandardLocalNames::id)
{
const QString normalized(value.toString().simplified());
if(QXmlUtils::isNCName(normalized))
{
const QXmlName::LocalNameCode id = m_namePool->allocateLocalName(normalized);
const int oldSize = m_document->m_IDs.count();
m_document->m_IDs.insert(id, currentParent());
/* We don't run the value through m_attributeCompress here, because
* the likelyhood of it deing identical to another attribute is
* very small. */
m_document->data.insert(m_preNumber, normalized);
/**
* In the case that we're called for doc-available(), m_context is
* null, and we need to flag somehow that we failed to load this
* document.
*/
if(oldSize == m_document->m_IDs.count() && m_context) // TODO
{
Q_ASSERT(m_context);
m_context->error(QtXmlPatterns::tr("An %1-attribute with value %2 has already been declared.")
.arg(formatKeyword("xml:id"),
formatData(normalized)),
FromDocument ? ReportContext::FODC0002 : ReportContext::XQDY0091,
this);
}
}
else if(m_context) // TODO
{
Q_ASSERT(m_context);
/* If we're building from an XML Document(e.g, we're fed from QXmlStreamReader, we raise FODC0002,
* otherwise XQDY0091. */
m_context->error(QtXmlPatterns::tr("An %1-attribute must have a "
"valid %2 as value, which %3 isn't.").arg(formatKeyword("xml:id"),
formatType(m_namePool, BuiltinTypes::xsNCName),
formatData(value.toString())),
FromDocument ? ReportContext::FODC0002 : ReportContext::XQDY0091,
this);
}
}
else
m_document->data.insert(m_preNumber, *m_attributeCompress.insert(value.toString()));
}