本文整理汇总了C++中DOMNode::lookupNamespaceURI方法的典型用法代码示例。如果您正苦于以下问题:C++ DOMNode::lookupNamespaceURI方法的具体用法?C++ DOMNode::lookupNamespaceURI怎么用?C++ DOMNode::lookupNamespaceURI使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMNode
的用法示例。
在下文中一共展示了DOMNode::lookupNamespaceURI方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lookupNamespaceURI
const XMLCh* DOMNodeImpl::lookupNamespaceURI(const XMLCh* specifiedPrefix) const {
DOMNode *thisNode = castToNode(this);
short type = thisNode->getNodeType();
switch (type) {
case DOMNode::ELEMENT_NODE : {
const XMLCh* ns = thisNode->getNamespaceURI();
const XMLCh* prefix = thisNode->getPrefix();
if (ns != 0) {
// REVISIT: is it possible that prefix is empty string?
if (specifiedPrefix == 0 && prefix == specifiedPrefix) {
// looking for default namespace
return ns;
} else if (prefix != 0 && XMLString::equals(prefix, specifiedPrefix)) {
// non default namespace
return ns;
}
}
if (thisNode->hasAttributes()) {
DOMNamedNodeMap *nodeMap = thisNode->getAttributes();
if(nodeMap != 0) {
int length = nodeMap->getLength();
for (int i = 0;i < length;i++) {
DOMNode *attr = nodeMap->item(i);
const XMLCh *attrPrefix = attr->getPrefix();
const XMLCh *value = attr->getNodeValue();
ns = attr->getNamespaceURI();
if (ns != 0 && XMLString::equals(ns, XMLUni::fgXMLNSURIName)) {
// at this point we are dealing with DOM Level 2 nodes only
if (specifiedPrefix == 0 &&
XMLString::equals(attr->getNodeName(), XMLUni::fgXMLNSString)) {
// default namespace
return value;
} else if (attrPrefix != 0 &&
XMLString::equals(attrPrefix, XMLUni::fgXMLNSString) &&
XMLString::equals(attr->getLocalName(), specifiedPrefix)) {
// non default namespace
return value;
}
}
}
}
}
DOMNode *ancestor = getElementAncestor(thisNode);
if (ancestor != 0) {
return ancestor->lookupNamespaceURI(specifiedPrefix);
}
return 0;
}
case DOMNode::DOCUMENT_NODE : {
return((DOMDocument*)thisNode)->getDocumentElement()->lookupNamespaceURI(specifiedPrefix);
}
case DOMNode::ENTITY_NODE :
case DOMNode::NOTATION_NODE:
case DOMNode::DOCUMENT_FRAGMENT_NODE:
case DOMNode::DOCUMENT_TYPE_NODE:
// type is unknown
return 0;
case DOMNode::ATTRIBUTE_NODE:{
if (fOwnerNode->getNodeType() == DOMNode::ELEMENT_NODE) {
return fOwnerNode->lookupNamespaceURI(specifiedPrefix);
}
return 0;
}
default:{
DOMNode *ancestor = getElementAncestor(castToNode(this));
if (ancestor != 0) {
return ancestor->lookupNamespaceURI(specifiedPrefix);
}
return 0;
}
}
}