mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Not part of regular build. Added getNameSpace method.
This commit is contained in:
parent
69e772b8e3
commit
f11de4ec67
@ -21,13 +21,13 @@
|
||||
* Keith Visco
|
||||
* -- original author.
|
||||
*
|
||||
* $Id: XMLDOMUtils.cpp,v 1.8 2001/01/12 20:06:16 axel%pike.org Exp $
|
||||
* $Id: XMLDOMUtils.cpp,v 1.9 2001/01/22 09:32:40 kvisco%ziplink.net Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* XMLDOMUtils
|
||||
* @author <a href="mailto:kvisco@ziplink.net">Keith Visco</a>
|
||||
* @version $Revision: 1.8 $ $Date: 2001/01/12 20:06:16 $
|
||||
* @version $Revision: 1.9 $ $Date: 2001/01/22 09:32:40 $
|
||||
**/
|
||||
|
||||
#include "XMLDOMUtils.h"
|
||||
@ -176,3 +176,38 @@ void XMLDOMUtils::getNodeValue(Node* node, String* target) {
|
||||
|
||||
} //-- getNodeValue
|
||||
|
||||
/**
|
||||
* Resolves the namespace for the given prefix. The namespace is put
|
||||
* into the dest argument.
|
||||
*
|
||||
* @return true if the namespace was found
|
||||
**/
|
||||
MBool XMLDOMUtils::getNameSpace
|
||||
(const String& prefix, Element* element, String& dest)
|
||||
{
|
||||
String attName("xmlns");
|
||||
if (prefix.length() > 0) {
|
||||
attName.append(':');
|
||||
attName.append(prefix);
|
||||
}
|
||||
|
||||
dest.clear();
|
||||
|
||||
Element* elem = element;
|
||||
while( elem ) {
|
||||
NamedNodeMap* atts = elem->getAttributes();
|
||||
if ( atts ) {
|
||||
Node* attr = atts->getNamedItem(attName);
|
||||
if (attr) {
|
||||
dest.append(attr->getNodeValue());
|
||||
return MB_TRUE;
|
||||
}
|
||||
}
|
||||
Node* node = elem->getParentNode();
|
||||
if ((!node) || (node->getNodeType() != Node::ELEMENT_NODE)) break;
|
||||
elem = (Element*) node;
|
||||
}
|
||||
return MB_FALSE;
|
||||
|
||||
} //-- getNameSpace
|
||||
|
||||
|
@ -21,12 +21,13 @@
|
||||
* Keith Visco
|
||||
* -- original author.
|
||||
*
|
||||
* $Id: XMLDOMUtils.h,v 1.7 2000/08/27 05:58:57 kvisco%ziplink.net Exp $
|
||||
* $Id: XMLDOMUtils.h,v 1.8 2001/01/22 09:32:40 kvisco%ziplink.net Exp $
|
||||
*/
|
||||
|
||||
|
||||
#include "dom.h"
|
||||
#include "NamespaceResolver.h"
|
||||
#include "baseutils.h"
|
||||
|
||||
#ifndef TRANSFRMX_XMLDOMUTILS_H
|
||||
#define TRANSFRMX_XMLDOMUTILS_H
|
||||
@ -50,6 +51,10 @@ public:
|
||||
**/
|
||||
static void getNodeValue(Node* node, String* target);
|
||||
|
||||
/**
|
||||
* Returns the Namespace associated with the given prefix
|
||||
**/
|
||||
static MBool getNameSpace(const String& prefix, Element* element, String& dest);
|
||||
|
||||
}; //-- XMLDOMUtils
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user