axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nadira...@apache.org
Subject svn commit: r431291 - in /webservices/axis/trunk/c/src/xml: XMLParser.h guththila/XMLParserGuththila.cpp xerces/XMLParserXerces.cpp
Date Mon, 14 Aug 2006 05:00:47 GMT
Author: nadiramra
Date: Sun Aug 13 22:00:46 2006
New Revision: 431291

URL: http://svn.apache.org/viewvc?rev=431291&view=rev
Log:
AXISCPP-770 XMLParserXerces::next(bool isCharData) crashes - more complete fix

Modified:
    webservices/axis/trunk/c/src/xml/XMLParser.h
    webservices/axis/trunk/c/src/xml/guththila/XMLParserGuththila.cpp
    webservices/axis/trunk/c/src/xml/xerces/XMLParserXerces.cpp

Modified: webservices/axis/trunk/c/src/xml/XMLParser.h
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/xml/XMLParser.h?rev=431291&r1=431290&r2=431291&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/xml/XMLParser.h (original)
+++ webservices/axis/trunk/c/src/xml/XMLParser.h Sun Aug 13 22:00:46 2006
@@ -126,13 +126,14 @@
      *         of the current XML element. See AnyElement.h for the structure
      *         of AnyElement.
      */
-	virtual const char* peek()=0; //Chinthana:Add the method to peek head and find the next
element 26/04/2005.
+    virtual const AnyElement* anyNext()=0;
+    
     /**
      * @brief  Peek a head and get the next elemnt. .
-     * @param  peek is pointer to bool type wich have to set true in side this method.
      * @return Return the name of the next element. 
      */
-    virtual const AnyElement* anyNext()=0;
+    virtual const char* peek()=0;      
+
     /**
      * Gets the corresponding prefix string for a given namespace. The
      * Parser should store the prefix/namespace pairs that it finds and
@@ -145,9 +146,16 @@
      * @return The prefix if a match is found. NULL otherwise. 
      */
     virtual const XML_Ch* getPrefix4NS(const XML_Ch* pcNS)=0;
+
+    /**
+     * @brief  Whether there is more data to parse.
+     * @return true if more data to parse; false otherwise. 
+     */
+    virtual bool canParseMore() { return m_bCanParseMore; }
+
 protected:
     AxisIOStream* m_pInputStream;
-
+    bool m_bCanParseMore;
 };
 
 #endif

Modified: webservices/axis/trunk/c/src/xml/guththila/XMLParserGuththila.cpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/xml/guththila/XMLParserGuththila.cpp?rev=431291&r1=431290&r2=431291&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/xml/guththila/XMLParserGuththila.cpp (original)
+++ webservices/axis/trunk/c/src/xml/guththila/XMLParserGuththila.cpp Sun Aug 13 22:00:46
2006
@@ -28,6 +28,11 @@
   element.m_pchNamespace = 0;
   element.m_pchNameOrValue = 0;
   element.m_pchAttributes[0] = 0;
+  
+  // This is just to set it up. Not sure if this 
+  // parser is functional - if so, following needs
+  // to be set correctly.
+  m_bCanParseMore = true;
 }
 
 

Modified: webservices/axis/trunk/c/src/xml/xerces/XMLParserXerces.cpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/xml/xerces/XMLParserXerces.cpp?rev=431291&r1=431290&r2=431291&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/xml/xerces/XMLParserXerces.cpp (original)
+++ webservices/axis/trunk/c/src/xml/xerces/XMLParserXerces.cpp Sun Aug 13 22:00:46 2006
@@ -37,6 +37,7 @@
     m_bPeeked = false;
     m_pParser = XMLReaderFactory::createXMLReader();
     m_pInputSource = NULL;
+    m_bCanParseMore = false;
 }
 
 XMLParserXerces::~XMLParserXerces()
@@ -87,11 +88,11 @@
 //    Try this again at some point in the future.  At the moment it works on
 //    Windows, but Linux has a problem...will keep for OS/400
 #ifndef __OS400__           
-        m_pParser->parseFirst( *m_pInputSource, m_ScanToken);
+        m_bCanParseMore = m_pParser->parseFirst( *m_pInputSource, m_ScanToken);
 #else
         try
         {
-            m_pParser->parseFirst( *m_pInputSource, m_ScanToken);
+            m_bCanParseMore = m_pParser->parseFirst( *m_pInputSource, m_ScanToken);
         }
         catch( const XMLException& toCatch)
         {
@@ -132,9 +133,8 @@
     if(!m_bPeeked) 
         m_Xhandler.freeElement();
     
-    bool bCanParseMore = true;
     AnyElement* elem;
-    while (bCanParseMore)
+    while (m_bCanParseMore && AXIS_FAIL != m_Xhandler.getStatus())
     {
         // See if we have a token to consume
         elem = m_Xhandler.getAnyElement();
@@ -145,11 +145,7 @@
         // If we do not have an element, then parse next token; else if
         // whitespace, ignore whitespace; else return token
         if (!elem)
-        {     
-            bCanParseMore = m_pParser->parseNext(m_ScanToken);
-            if (AXIS_FAIL == m_Xhandler.getStatus())
-                break;
-        }
+            m_bCanParseMore = m_pParser->parseNext(m_ScanToken);
         else if (!isCharData && (CHARACTER_ELEMENT == elem->m_type))
             m_Xhandler.freeElement();
         else
@@ -166,20 +162,21 @@
     {
         if(!m_bFirstParsed)
         {
-            m_pParser->parseFirst(*m_pInputSource, m_ScanToken);
+            m_bCanParseMore = m_pParser->parseFirst(*m_pInputSource, m_ScanToken);
             m_bFirstParsed = true;
         }
         
         m_Xhandler.freeElement();
         
         AnyElement* elem;
-        while (m_pParser->parseNext(m_ScanToken) && AXIS_FAIL != m_Xhandler.getStatus())
-        {                             
+        while (m_bCanParseMore && AXIS_FAIL != m_Xhandler.getStatus())
+        {
             // Attempt to get token
+            m_bCanParseMore = m_pParser->parseNext(m_ScanToken);                     
      
             elem = m_Xhandler.getAnyElement();
             
             // we never peek for char data hence this is a white space - ignore it.
-            if (elem && CHARACTER_ELEMENT == elem->m_type)
+            if (m_bCanParseMore && elem && CHARACTER_ELEMENT == elem->m_type)
                 m_Xhandler.freeElement();
             else
                 break;
@@ -200,49 +197,39 @@
 
 const AnyElement* XMLParserXerces::anyNext()
 {
-    bool bCanParseMore = false;
-    
     // Say the SAX event handler to record prefix mappings too 
     // By default the event handler do not record them.
     m_Xhandler.setGetPrefixMappings(true);
     if(!m_bFirstParsed)
     {
-        m_pParser->parseFirst(*m_pInputSource, m_ScanToken);
+        m_bCanParseMore = m_pParser->parseFirst(*m_pInputSource, m_ScanToken);
         m_bFirstParsed = true;
     }
 
     if(!m_bPeeked) 
         m_Xhandler.freeElement();
 
-    while (true)
+    AnyElement* elem;
+    while (m_bCanParseMore && AXIS_FAIL != m_Xhandler.getStatus())
     {
-        AnyElement* elem = m_Xhandler.getAnyElement();
+        // See if we have a token to consume
+        elem = m_Xhandler.getAnyElement();
+        
+        // Since we have consumed whatever is there, ensure peek flag is set to false
+        m_bPeeked = false;
+        
+        // If we do not have an element, then parse next token;  
+        // else return token
         if (!elem)
-        {
-            if(!m_bPeeked) 
-                bCanParseMore = m_pParser->parseNext(m_ScanToken);
-            else
-            {
-                m_bPeeked = false;
-                bCanParseMore = true;
-            }
-
-            elem = m_Xhandler.getAnyElement();
-        }
-        if (elem)
+            m_bCanParseMore = m_pParser->parseNext(m_ScanToken);
+        else
         {
             m_Xhandler.setGetPrefixMappings(false);
-
-            if( m_bPeeked )
-                m_bPeeked = false;
-
             return elem;
         }
-        else if (AXIS_FAIL == m_Xhandler.getStatus()) 
-            return NULL;
-        else if (!bCanParseMore) 
-            return NULL;
     }
+    
+    return NULL;
 }
 
 const XML_Ch* XMLParserXerces::getPrefix4NS(const XML_Ch* pcNS)



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


Mime
View raw message