In our code we have many loops of the form....

XMLCh *namespace = ...                               
XMLCh *elementName = ...         
DOMNodeList *domNodeList =  
domElement->getElementsByTagNameNS(namespace, elementName);                     
           
XMLSize_t domNodeListSize = domNodeList->getLength();           
for (XMLSize_t count = 0; count < domNodeListSize; ++count) {                   
                        
    DOMElement *nextDOMElement = (DOMElement *) domNodeList->item(count);
    // Modify nextDOMElement by adding attributes
}

These are extremely slow.

The problem seems to be multi-fold:

1. The API has no getElementsByTagNameNS() that returns a "const DOMNodeList*", 
thus allowing optimizations. (Not xerces-c's fault, but it's a nice-to-have!)
2. DOMNodeList:: getLength() is order O(V + E), where V is the number of 
DOMElements under domElement and E is the number of edges
3. DOMNodeList:: item(XMLSize_t index) is of oder O(V + E) as nextDOMElement's 
attributes are modified and thus the DOMDocument's fChanges is incremented

These yield a for loop that is of O((V + E)^2), which for the number of such 
loops we have is far, far to slow.

Short of re-writing DOMDeepNodeListImpl, what is the proper solution to this 
problem?

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to