зеркало из https://github.com/mozilla/pjs.git
Added the generateId method
This commit is contained in:
Родитель
04bfd1b289
Коммит
6e5344b42f
|
@ -19,13 +19,13 @@
|
|||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
*
|
||||
* $Id: DOMHelper.cpp,v 1.1 2000-02-22 11:12:57 kvisco%ziplink.net Exp $
|
||||
* $Id: DOMHelper.cpp,v 1.2 2000-04-19 10:31:23 kvisco%ziplink.net Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* A class used to overcome DOM 1.0 deficiencies
|
||||
* @author <a href="mailto:kvisco@ziplink.net">Keith Visco</a>
|
||||
* @version $Revision: 1.1 $ $Date: 2000-02-22 11:12:57 $
|
||||
* @version $Revision: 1.2 $ $Date: 2000-04-19 10:31:23 $
|
||||
**/
|
||||
|
||||
#include "DOMHelper.h"
|
||||
|
@ -72,6 +72,37 @@ Node* DOMHelper::appearsFirst(Node* node1, Node* node2) {
|
|||
|
||||
} //-- compareDocumentOrders
|
||||
|
||||
/**
|
||||
* Generates a unique ID for the given node and places the result in
|
||||
* dest
|
||||
**/
|
||||
void DOMHelper::generateId(Node* node, String& dest) {
|
||||
|
||||
if (!node) {
|
||||
dest.append("<null>");
|
||||
return;
|
||||
}
|
||||
|
||||
dest.append("id");
|
||||
|
||||
if (node->getNodeType() == Node::DOCUMENT_NODE) {
|
||||
Integer::toString((int)node,dest);
|
||||
return;
|
||||
}
|
||||
|
||||
Integer::toString((int)node->getOwnerDocument(), dest);
|
||||
|
||||
OrderInfo* orderInfo = getDocumentOrder(node);
|
||||
|
||||
int i = 0;
|
||||
while (i < orderInfo->size) {
|
||||
dest.append('.');
|
||||
Integer::toString(orderInfo->order[i], dest);
|
||||
++i;
|
||||
}
|
||||
|
||||
} //-- generateId
|
||||
|
||||
/**
|
||||
* Returns the parent of the given node. This method is available
|
||||
* mainly to compensate for the fact that Attr nodes in DOM 1.0
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
*
|
||||
* $Id: DOMHelper.h,v 1.2 2000-04-12 22:32:17 nisheeth%netscape.com Exp $
|
||||
* $Id: DOMHelper.h,v 1.3 2000-04-19 10:31:32 kvisco%ziplink.net Exp $
|
||||
*/
|
||||
|
||||
#ifndef TRANSFRMX_DOMHELPER_H
|
||||
|
@ -31,7 +31,7 @@
|
|||
#include "dom.h"
|
||||
#include "HashTable.h"
|
||||
#include "MITREObject.h"
|
||||
|
||||
#include "primitives.h"
|
||||
|
||||
|
||||
//----------------------/
|
||||
|
@ -59,7 +59,7 @@ class OrderInfo : public MITREObject {
|
|||
/**
|
||||
* A class used to overcome DOM 1.0 deficiencies
|
||||
* @author <a href="mailto:kvisco@ziplink.net">Keith Visco</a>
|
||||
* @version $Revision: 1.2 $ $Date: 2000-04-12 22:32:17 $
|
||||
* @version $Revision: 1.3 $ $Date: 2000-04-19 10:31:32 $
|
||||
**/
|
||||
class DOMHelper {
|
||||
|
||||
|
@ -84,6 +84,12 @@ public:
|
|||
**/
|
||||
Node* appearsFirst(Node* node1, Node* node2);
|
||||
|
||||
/**
|
||||
* Generates a unique ID for the given node and places the result in
|
||||
* dest
|
||||
**/
|
||||
void generateId(Node* node, String& dest);
|
||||
|
||||
/**
|
||||
* Returns the child number of the given node. Numbering
|
||||
* starts at 1 for all nodes except the Document node and
|
||||
|
|
Загрузка…
Ссылка в новой задаче