//
// domCheckSum  -  Compute the check sum for a DOM node.
//                 Works recursively - initially called with a document node.
//
void ThreadParser::domCheckSum(const DOMNode *node)
{
    const XMLCh        *s;
    DOMNode          *child;
    DOMNamedNodeMap  *attributes;

    switch (node->getNodeType() )
    {
    case DOMNode::ELEMENT_NODE:
        {
            s = node->getNodeName();   // the element name

            attributes = node->getAttributes();  // Element's attributes
            int numAttributes = attributes->getLength();
            int i;
            for (i=0; i<numAttributes; i++)
                domCheckSum(attributes->item(i));

            addToCheckSum(s);          // Content and Children
            for (child=node->getFirstChild(); child!=0; child=child->getNextSibling())
                domCheckSum(child);

            break;
        }

    case DOMNode::ATTRIBUTE_NODE:
        {
            s = node->getNodeName();  // The attribute name
            addToCheckSum(s);
            s = node->getNodeValue();  // The attribute value
            if (s != 0)
                addToCheckSum(s);
            break;
        }

    case DOMNode::TEXT_NODE:
    case DOMNode::CDATA_SECTION_NODE:
        {
            s = node->getNodeValue();
            addToCheckSum(s);
            break;
        }

    case DOMNode::ENTITY_REFERENCE_NODE:
    case DOMNode::DOCUMENT_NODE:
        {
            // For entity references and the document, nothing is dirctly
            //  added to the checksum, but we do want to process the chidren nodes.
            //
            for (child=node->getFirstChild(); child!=0; child=child->getNextSibling())
                domCheckSum(child);
            break;
        }
    }
}
Ejemplo n.º 2
0
 void ignorableWhitespace(const XMLCh* const chars, const XMLSize_t length) {
     addToCheckSum(chars, length);
 }
Ejemplo n.º 3
0
 //  These are the SAX call-back functions that this class implements. Can be used
 //  for SAX and SAX2.
 void characters(const XMLCh* const chars, const XMLSize_t length) {
     addToCheckSum(chars, length);
 }
 void ignorableWhitespace(const XMLCh* const chars, const unsigned int length) {
     addToCheckSum(chars, length);
 };
 //  These are the SAX call-back functions that this class implements. Can be used
 //  for SAX and SAX2.
 void characters(const XMLCh* const chars, const unsigned int length) {
     addToCheckSum(chars, length);
 };