コード例 #1
0
ファイル: DOMNodeImpl.cpp プロジェクト: JohnWilliam1988/TCIDE
const XMLCh* DOMNodeImpl::lookupPrefix(const XMLCh* namespaceURI) const {
    // REVISIT: When Namespaces 1.1 comes out this may not be true
    // Prefix can't be bound to null namespace
    if (namespaceURI == 0) {
        return 0;
    }

    DOMNode *thisNode = castToNode(this);

    short type = thisNode->getNodeType();

    switch (type) {
    case DOMNode::ELEMENT_NODE: {
        return lookupPrefix(namespaceURI, (DOMElement*)thisNode);
    }
    case DOMNode::DOCUMENT_NODE:{
        return ((DOMDocument*)thisNode)->getDocumentElement()->lookupPrefix(namespaceURI);
    }

    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->lookupPrefix(namespaceURI);
        }
        return 0;
    }
    default:{
        DOMNode *ancestor = getElementAncestor(thisNode);
        if (ancestor != 0) {
            return ancestor->lookupPrefix(namespaceURI);
        }
        return 0;
    }
    }
}