本文整理汇总了C++中QDomElement::namespaceURI方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomElement::namespaceURI方法的具体用法?C++ QDomElement::namespaceURI怎么用?C++ QDomElement::namespaceURI使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomElement
的用法示例。
在下文中一共展示了QDomElement::namespaceURI方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
/// \cond
void QXmppJingleIq::Content::parse(const QDomElement &element)
{
m_creator = element.attribute("creator");
m_disposition = element.attribute("disposition");
m_name = element.attribute("name");
m_senders = element.attribute("senders");
// description
QDomElement descriptionElement = element.firstChildElement("description");
m_descriptionType = descriptionElement.namespaceURI();
m_descriptionMedia = descriptionElement.attribute("media");
QDomElement child = descriptionElement.firstChildElement("payload-type");
while (!child.isNull())
{
QXmppJinglePayloadType payload;
payload.parse(child);
m_payloadTypes << payload;
child = child.nextSiblingElement("payload-type");
}
// transport
QDomElement transportElement = element.firstChildElement("transport");
m_transportType = transportElement.namespaceURI();
m_transportUser = transportElement.attribute("ufrag");
m_transportPassword = transportElement.attribute("pwd");
child = transportElement.firstChildElement("candidate");
while (!child.isNull())
{
QXmppJingleCandidate candidate;
candidate.parse(child);
m_transportCandidates << candidate;
child = child.nextSiblingElement("candidate");
}
}
示例2: d
/**
* Constructs stream-error object from a DOM element.
*
* @param element \<stream:error/\> DOM element.
*/
StreamError::StreamError(const QDomElement& element)
: d(new Private)
{
QDomNode root = d->doc.importNode(element, true);
d->doc.appendChild(root);
QDomNodeList childs = root.childNodes();
for (int i = 0; i < childs.count(); ++i) {
QDomElement element = childs.item(i).toElement();
if (element.namespaceURI() == NS_STREAMS) {
int condition = Private::stringToCondition(element.tagName() );
if ( condition != -1 ) {
d->errorCondition = element;
break;
}
}
}
QDomElement eText = root.firstChildElement("text");
if (eText.namespaceURI() == NS_STREAMS) {
d->text = eText;
}
for (int i = 0; i < childs.count(); ++i) {
QDomElement element = childs.item(i).toElement();
/* first element outside NS_STREAMS ns will be an app-specific error condition */
if (element.namespaceURI() != NS_STREAMS) {
d->appSpec = element;
}
}
}
示例3: stripAnswers
QString XmlUtil::stripAnswers(const QString &input) {
QDomDocument doc;
doc.setContent(input);
QDomElement docElem = doc.documentElement();
QDomNode n = docElem.firstChild();
while ( !n.isNull() ) {
QDomElement e = n.toElement();
if ( !e.isNull() && (e.namespaceURI().isEmpty() || e.namespaceURI() == XML_NS) ) {
if ( e.nodeName() == "choose" ) {
QDomElement c = e.firstChildElement("choice");
while ( !c.isNull() ) {
c.removeAttribute("answer");
c = c.nextSiblingElement("choice");
}
} else if ( e.nodeName() == "identification" ) {
QDomElement a = e.firstChildElement("a");
while ( !a.isNull() ) {
e.removeChild(a);
a = e.firstChildElement("a");
}
}
}
n = n.nextSibling();
}
return doc.toString(2);
}
示例4: saveData
QString PrivateStorage::saveData(const Jid &AStreamJid, const QDomElement &AElement)
{
if (FStanzaProcessor && isOpen(AStreamJid) && !AElement.tagName().isEmpty() && !AElement.namespaceURI().isEmpty())
{
Stanza request(STANZA_KIND_IQ);
request.setType(STANZA_TYPE_SET).setUniqueId();
QDomElement elem = request.addElement("query",NS_JABBER_PRIVATE);
elem.appendChild(AElement.cloneNode(true));
if (FStanzaProcessor->sendStanzaRequest(this,AStreamJid,request,PRIVATE_STORAGE_TIMEOUT))
{
LOG_STRM_INFO(AStreamJid,QString("Private data save request sent, ns=%1, id=%2").arg(AElement.namespaceURI(),request.id()));
if (FPreClosedStreams.contains(AStreamJid))
notifyDataChanged(AStreamJid,AElement.tagName(),AElement.namespaceURI());
FSaveRequests.insert(request.id(),insertElement(AStreamJid,AElement));
return request.id();
}
else
{
LOG_STRM_WARNING(AStreamJid,QString("Failed to send private data save request, ns=%1").arg(AElement.namespaceURI()));
}
}
else if (!isOpen(AStreamJid))
{
REPORT_ERROR("Failed to save private data: Storage is not opened");
}
else if (AElement.tagName().isEmpty() || AElement.namespaceURI().isEmpty())
{
REPORT_ERROR("Failed to save private data: Invalid data");
}
return QString::null;
}
示例5: parse
void QXmppStreamFeatures::parse(const QDomElement &element)
{
m_bindMode = readFeature(element, "bind", ns_bind);
m_sessionMode = readFeature(element, "session", ns_session);
m_nonSaslAuthMode = readFeature(element, "auth", ns_authFeature);
m_tlsMode = readFeature(element, "starttls", ns_tls);
m_streamManagementMode = readFeature(element, "sm", ns_stream_management);
// parse advertised compression methods
QDomElement compression = element.firstChildElement("compression");
if (compression.namespaceURI() == ns_compressFeature)
{
QDomElement subElement = compression.firstChildElement("method");
while(!subElement.isNull())
{
m_compressionMethods << subElement.text();
subElement = subElement.nextSiblingElement("method");
}
}
// parse advertised SASL Authentication mechanisms
QDomElement mechs = element.firstChildElement("mechanisms");
if (mechs.namespaceURI() == ns_sasl)
{
QDomElement subElement = mechs.firstChildElement("mechanism");
while(!subElement.isNull()) {
m_authMechanisms << subElement.text();
subElement = subElement.nextSiblingElement("mechanism");
}
}
}
示例6: writeElementChilds
void FileWriter::writeElementChilds(const QDomElement &AParent)
{
QDomNode node = AParent.firstChild();
while (!node.isNull())
{
if (node.isElement())
{
QDomElement elem = node.toElement();
if (elem.tagName() != "thread")
{
FXmlWriter->writeStartElement(elem.tagName());
QString elemNs = elem.namespaceURI();
if (!elemNs.isEmpty() && elem.parentNode().namespaceURI()!=elemNs)
FXmlWriter->writeAttribute("xmlns",elem.namespaceURI());
QDomNamedNodeMap attrMap = elem.attributes();
for (uint i=0; i<attrMap.length(); i++)
{
QDomNode attrNode = attrMap.item(i);
FXmlWriter->writeAttribute(attrNode.nodeName(), attrNode.nodeValue());
}
writeElementChilds(elem);
FXmlWriter->writeEndElement();
}
}
else if (node.isCharacterData())
{
FXmlWriter->writeCharacters(node.toCharacterData().data());
}
node = node.nextSibling();
}
}
示例7: stanzaRequestResult
void PrivateStorage::stanzaRequestResult(const Jid &AStreamJid, const Stanza &AStanza)
{
if (FSaveRequests.contains(AStanza.id()))
{
QDomElement dataElem = FSaveRequests.take(AStanza.id());
if (AStanza.isResult())
{
LOG_STRM_INFO(AStreamJid,QString("Private data saved on server, ns=%1, id=%2").arg(dataElem.namespaceURI(),AStanza.id()));
notifyDataChanged(AStreamJid,dataElem.tagName(),dataElem.namespaceURI());
}
else
{
LOG_STRM_WARNING(AStreamJid,QString("Private data saved in local storage, ns=%1, id=%2: %3").arg(dataElem.namespaceURI(),AStanza.id(),XmppStanzaError(AStanza).condition()));
}
saveOptionsElement(AStreamJid,dataElem);
emit dataSaved(AStanza.id(),AStreamJid,dataElem);
}
else if (FLoadRequests.contains(AStanza.id()))
{
QDomElement dataElem;
QDomElement loadElem = FLoadRequests.take(AStanza.id());
if (AStanza.isResult())
{
dataElem = AStanza.firstElement("query",NS_JABBER_PRIVATE).firstChildElement(loadElem.tagName());
LOG_STRM_INFO(AStreamJid,QString("Private data loaded from server, ns=%1, id=%2").arg(loadElem.namespaceURI(),AStanza.id()));
}
else
{
LOG_STRM_WARNING(AStreamJid,QString("Private data loaded from local storage, ns=%1, id=%2: %3").arg(loadElem.namespaceURI(),AStanza.id(),XmppStanzaError(AStanza).condition()));
}
if (dataElem.isNull())
dataElem = loadOptionsElement(AStreamJid,loadElem.tagName(),loadElem.namespaceURI());
emit dataLoaded(AStanza.id(),AStreamJid,insertElement(AStreamJid,dataElem));
}
else if (FRemoveRequests.contains(AStanza.id()))
{
QDomElement dataElem = FRemoveRequests.take(AStanza.id());
if (AStanza.isResult())
{
LOG_STRM_INFO(AStreamJid,QString("Private data removed from server, ns=%1, id=%2").arg(dataElem.namespaceURI(),AStanza.id()));
notifyDataChanged(AStreamJid,dataElem.tagName(),dataElem.namespaceURI());
}
else
{
LOG_STRM_WARNING(AStreamJid,QString("Private data removed from local storage, ns=%1, id=%2: %3").arg(dataElem.namespaceURI(),AStanza.id(),XmppStanzaError(AStanza).condition()));
}
removeElement(AStreamJid,dataElem.tagName(),dataElem.namespaceURI());
removeOptionsElement(AStreamJid,dataElem.tagName(),dataElem.namespaceURI());
emit dataRemoved(AStanza.id(),AStreamJid,dataElem);
}
}
示例8: helperToXmlAddDomElement
static void helperToXmlAddDomElement(QXmlStreamWriter* stream, const QDomElement& element, const QStringList &omitNamespaces)
{
stream->writeStartElement(element.tagName());
/* attributes */
QString xmlns = element.namespaceURI();
if (!xmlns.isEmpty() && !omitNamespaces.contains(xmlns))
stream->writeAttribute("xmlns", xmlns);
QDomNamedNodeMap attrs = element.attributes();
for (int i = 0; i < attrs.size(); i++)
{
QDomAttr attr = attrs.item(i).toAttr();
stream->writeAttribute(attr.name(), attr.value());
}
/* children */
QDomNode childNode = element.firstChild();
while (!childNode.isNull())
{
if (childNode.isElement())
{
helperToXmlAddDomElement(stream, childNode.toElement(), QStringList() << xmlns);
} else if (childNode.isText()) {
stream->writeCharacters(childNode.toText().data());
}
childNode = childNode.nextSibling();
}
stream->writeEndElement();
}
示例9: handleStanza
bool QXmppCarbonManager::handleStanza(const QDomElement &element)
{
if(element.tagName() != "message")
return false;
bool sent = true;
QDomElement carbon = element.firstChildElement("sent");
if(carbon.isNull()) {
carbon = element.firstChildElement("received");
sent = false;
}
if(carbon.isNull() || carbon.namespaceURI() != ns_carbons)
return false; // Neither sent nor received -> no carbon message
QDomElement forwarded = carbon.firstChildElement("forwarded");
if(forwarded.isNull())
return false;
QDomElement messageelement = forwarded.firstChildElement("message");
if(messageelement.isNull())
return false;
QXmppMessage message;
message.parse(messageelement);
if(sent)
emit messageSent(message);
else
emit messageReceived(message);
return true;
}
示例10: getData
QDomElement PrivateStorage::getData(const Jid &AStreamJid, const QString &ATagName, const QString &ANamespace) const
{
QDomElement elem = FStreamElements.value(AStreamJid).firstChildElement(ATagName);
while (!elem.isNull() && elem.namespaceURI()!=ANamespace)
elem= elem.nextSiblingElement(ATagName);
return elem;
}
示例11: isRpcResponseIq
/// \cond
bool QXmppRpcResponseIq::isRpcResponseIq(const QDomElement &element)
{
QString type = element.attribute("type");
QDomElement dataElement = element.firstChildElement("query");
return dataElement.namespaceURI() == ns_rpc &&
type == "result";
}
示例12: dublinCoreNamespace
QList<QDomElement> Item::unhandledElements() const
{
// TODO: do not hardcode this list here
QList<ElementType> handled;
handled.append(ElementType(QLatin1String("title")));
handled.append(ElementType(QLatin1String("link")));
handled.append(ElementType(QLatin1String("description")));
handled.append(ElementType(QLatin1String("pubDate")));
handled.append(ElementType(QLatin1String("expirationDate")));
handled.append(ElementType(QLatin1String("rating")));
handled.append(ElementType(QLatin1String("source")));
handled.append(ElementType(QLatin1String("guid")));
handled.append(ElementType(QLatin1String("comments")));
handled.append(ElementType(QLatin1String("author")));
handled.append(ElementType(QLatin1String("date"), dublinCoreNamespace()));
QList<QDomElement> notHandled;
QDomNodeList children = element().childNodes();
for (int i = 0; i < children.size(); ++i)
{
QDomElement el = children.at(i).toElement();
if (!el.isNull()
&& !handled.contains(ElementType(el.localName(), el.namespaceURI())))
{
notHandled.append(el);
}
}
return notHandled;
}
示例13: loadAnnotations
void Reader::loadAnnotations(const QDomElement& annotations)
{
QDomNodeList nodes = annotations.childNodes();
for(int n=0;n<nodes.count();++n) {
QDomElement e = nodes.at(n).toElement();
if(e.isNull())
continue;
if(e.namespaceURI()==DP_NAMESPACE && e.localName()=="a") {
_commands.append(MessagePtr(new protocol::AnnotationCreate(
0,
++_annotationid,
e.attribute("x").toInt(),
e.attribute("y").toInt(),
e.attribute("w").toInt(),
e.attribute("h").toInt()
)));
_commands.append(MessagePtr(new protocol::AnnotationEdit(
_annotationid,
e.attribute("bg").mid(1).toUInt(0,16),
e.text()
)));
} else {
qWarning() << "unhandled annotations (DP ext.) element:" << e.tagName();
}
}
}
示例14: element
QList<QDomElement> Entry::unhandledElements() const
{
// TODO: do not hardcode this list here
QList<ElementType> handled;
handled.append(ElementType(QLatin1String("author"), atom1Namespace()));
handled.append(ElementType(QLatin1String("contributor"), atom1Namespace()));
handled.append(ElementType(QLatin1String("category"), atom1Namespace()));
handled.append(ElementType(QLatin1String("id"), atom1Namespace()));
handled.append(ElementType(QLatin1String("link"), atom1Namespace()));
handled.append(ElementType(QLatin1String("rights"), atom1Namespace()));
handled.append(ElementType(QLatin1String("source"), atom1Namespace()));
handled.append(ElementType(QLatin1String("published"), atom1Namespace()));
handled.append(ElementType(QLatin1String("updated"), atom1Namespace()));
handled.append(ElementType(QLatin1String("summary"), atom1Namespace()));
handled.append(ElementType(QLatin1String("title"), atom1Namespace()));
handled.append(ElementType(QLatin1String("content"), atom1Namespace()));
QList<QDomElement> notHandled;
QDomNodeList children = element().childNodes();
for (int i = 0; i < children.size(); ++i)
{
QDomElement el = children.at(i).toElement();
if (!el.isNull()
&& !handled.contains(ElementType(el.localName(), el.namespaceURI())))
{
notHandled.append(el);
}
}
return notHandled;
}
示例15: stripExtraNS
// stripExtraNS
//
// This function removes namespace information from various nodes for
// display purposes only (the element is pretty much useless for processing
// after this). We do this because QXml is a bit overzealous about outputting
// redundant namespaces.
static QDomElement stripExtraNS(const QDomElement &e)
{
// find closest parent with a namespace
QDomNode par = e.parentNode();
while(!par.isNull() && par.namespaceURI().isNull())
par = par.parentNode();
bool noShowNS = false;
if(!par.isNull() && par.namespaceURI() == e.namespaceURI())
noShowNS = true;
// build qName (prefix:localName)
QString qName;
if(!e.prefix().isEmpty())
qName = e.prefix() + ':' + e.localName();
else
qName = e.tagName();
QDomElement i;
int x;
if(noShowNS)
i = e.ownerDocument().createElement(qName);
else
i = e.ownerDocument().createElementNS(e.namespaceURI(), qName);
// copy attributes
QDomNamedNodeMap al = e.attributes();
for(x = 0; x < al.count(); ++x) {
QDomAttr a = al.item(x).cloneNode().toAttr();
// don't show xml namespace
if(a.namespaceURI() == NS_XML)
i.setAttribute(QString("xml:") + a.name(), a.value());
else
i.setAttributeNodeNS(a);
}
// copy children
QDomNodeList nl = e.childNodes();
for(x = 0; x < nl.count(); ++x) {
QDomNode n = nl.item(x);
if(n.isElement())
i.appendChild(stripExtraNS(n.toElement()));
else
i.appendChild(n.cloneNode());
}
return i;
}