You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by tn...@apache.org on 2001/05/23 15:14:32 UTC

cvs commit: xml-xerces/c/samples/IDOMCount IDOMCount.cpp

tng         01/05/23 06:14:32

  Modified:    c/samples/IDOMCount IDOMCount.cpp
  Log:
  IDOM: Incorrect element count.
  
  Revision  Changes    Path
  1.2       +9 -6      xml-xerces/c/samples/IDOMCount/IDOMCount.cpp
  
  Index: IDOMCount.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/samples/IDOMCount/IDOMCount.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IDOMCount.cpp	2001/05/17 15:28:08	1.1
  +++ IDOMCount.cpp	2001/05/23 13:14:31	1.2
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: IDOMCount.cpp,v 1.1 2001/05/17 15:28:08 tng Exp $
  + * $Id: IDOMCount.cpp,v 1.2 2001/05/23 13:14:31 tng Exp $
    */
   
   // ---------------------------------------------------------------------------
  @@ -105,12 +105,15 @@
   {
       IDOM_Node *child;
       int count = 0;
  -    for (child = n->getFirstChild(); child != 0; child=child->getNextSibling())
  +    if (n->getNodeType() == IDOM_Node::ELEMENT_NODE)
       {
  -        if (n->getNodeType() == IDOM_Node::ELEMENT_NODE)
  +        count++;
  +        for (child = n->getFirstChild(); child != 0; child=child->getNextSibling())
           {
  -            count++;
  -            count += countChildElements(child);
  +            if (child->getNodeType() == IDOM_Node::ELEMENT_NODE)
  +            {
  +                count += countChildElements(child);
  +            }
           }
       }
       return count;
  @@ -265,7 +268,7 @@
       {
           IDOM_Document *doc = parser.getDocument();
           //unsigned int elementCount = doc.getElementsByTagName("*").getLength();
  -        unsigned int elementCount = countChildElements(doc);
  +        unsigned int elementCount = countChildElements((IDOM_Node*)doc->getDocumentElement());
   
           // Print out the stats that we collected and time taken.
           cout << xmlFile << ": " << duration << " ms ("
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org