axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nadira...@apache.org
Subject svn commit: r382097 - in /webservices/axis/trunk/c/src/xml/xerces: XMLParserXerces.cpp XMLParserXerces.h
Date Wed, 01 Mar 2006 17:42:40 GMT
Author: nadiramra
Date: Wed Mar  1 09:42:39 2006
New Revision: 382097

URL: http://svn.apache.org/viewcvs?rev=382097&view=rev
Log:
Uncommented parser exception processing, fixed message clone bugs in uncommented code.

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

Modified: webservices/axis/trunk/c/src/xml/xerces/XMLParserXerces.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/xml/xerces/XMLParserXerces.cpp?rev=382097&r1=382096&r2=382097&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/xml/xerces/XMLParserXerces.cpp (original)
+++ webservices/axis/trunk/c/src/xml/xerces/XMLParserXerces.cpp Wed Mar  1 09:42:39 2006
@@ -32,14 +32,14 @@
 XMLParserXerces::XMLParserXerces()
 {
     m_bFirstParsed = false;
-	m_bPeeked = false;
+    m_bPeeked = false;
     m_pParser = XMLReaderFactory::createXMLReader();
     m_pInputSource = NULL;
 }
 
 XMLParserXerces::~XMLParserXerces()
 {
-    //Samisa - Parser has memory allocated with the last AnyElement parsed; clean that
+    // Parser has memory allocated with the last AnyElement parsed; clean that
     m_Xhandler.freeElement();
 
     if(m_pInputSource)
@@ -51,19 +51,20 @@
 int XMLParserXerces::setInputStream(AxisIOStream* pInputStream)
 {
     m_pInputStream = pInputStream;
-    //check if memeory is already allocated for is
+    
+    // check if memory is already allocated for is
     if(m_pInputSource)
         delete m_pInputSource;
     
     m_pInputSource = new SoapInputSource(pInputStream);
-	m_Xhandler.reset();
+    m_Xhandler.reset();
     m_pParser->setContentHandler(&m_Xhandler);
      if (m_bFirstParsed)
     {
         m_pParser->parseReset(m_ScanToken);
         m_bFirstParsed = false;
     }
-   /* return m_pHandler->Success(); */
+   
     return AXIS_SUCCESS;
 }
 
@@ -79,80 +80,69 @@
 
 const AnyElement* XMLParserXerces::next(bool isCharData)
 {
-	bool bCanParseMore = false;
+    bool bCanParseMore = false;
 
     if( !m_bFirstParsed)
     {
-		m_pParser->parseFirst( *m_pInputSource, m_ScanToken);
-/*
-	Try this again at some point in the future.  At the moment it works on
-	Windows, but Linux as a problem...
-		try
-		{
-			m_pParser->parseFirst( *m_pInputSource, m_ScanToken);
-		}
-		catch( const XMLException& toCatch)
-		{
-			char *	message = XMLString::transcode( toCatch.getMessage());
-
-// Clone the error message before deleting it.
-			char *	pErrorMsg = new char[strlen( message + 1)];
-
-			strcpy( pErrorMsg, message);
-
-			XMLString::release( &message);
-
-			throw AxisParseException( CLIENT_SOAP_CONTENT_NOT_SOAP, pErrorMsg);
-		}
-		catch( const SAXParseException& toCatch)
-		{
-			char *	message = XMLString::transcode( toCatch.getMessage());
-
-// Clone the error message before deleting it.
-			char *	pErrorMsg = new char[strlen( message + 1)];
-
-			strcpy( pErrorMsg, message);
-
-			XMLString::release( &message);
-
-			throw AxisParseException( CLIENT_SOAP_CONTENT_NOT_SOAP, pErrorMsg);
-		}
-		catch( HTTPTransportException & e)
-		{
-			throw;
-		}
-		catch( ...)
-		{
-			char *	pErrorMsg = "Unexpected Exception in SAX parser.  Probably no message or the message
is not recognised as XML.";
-
-			throw AxisParseException( CLIENT_SOAP_CONTENT_NOT_SOAP, pErrorMsg);
-		}
-*/
+        m_pParser->parseFirst( *m_pInputSource, m_ScanToken);
+
+        try
+        {
+            m_pParser->parseFirst( *m_pInputSource, m_ScanToken);
+        }
+        catch( const XMLException& toCatch)
+        {
+            char *    message = XMLString::transcode( toCatch.getMessage());
+
+            // Clone the error message before deleting it.
+            char *    pErrorMsg = new char[strlen( message ) + 1];
+            strcpy( pErrorMsg, message);
+            XMLString::release( &message);
+
+            throw AxisParseException( CLIENT_SOAP_CONTENT_NOT_SOAP, pErrorMsg);
+        }
+        catch( const SAXParseException& toCatch)
+        {
+            char *    message = XMLString::transcode( toCatch.getMessage());
+
+            // Clone the error message before deleting it.
+            char *    pErrorMsg = new char[strlen( message ) + 1];
+            strcpy( pErrorMsg, message);
+            XMLString::release( &message);
+
+            throw AxisParseException( CLIENT_SOAP_CONTENT_NOT_SOAP, pErrorMsg);
+        }
+        catch( HTTPTransportException & e)
+        {
+            throw;
+        }
+        catch( ...)
+        {
+            char *pErrorMsg = "Unexpected Exception in SAX parser.  Probably no message or
the message is not recognised as XML.";
+
+            throw AxisParseException( CLIENT_SOAP_CONTENT_NOT_SOAP, pErrorMsg);
+        }
+
         m_bFirstParsed = true;
     }
 
-	if(!m_bPeeked) 
-	{
-		m_Xhandler.freeElement();
-	}
+    if(!m_bPeeked) 
+        m_Xhandler.freeElement();
+    
     while (true)
     {
         AnyElement* elem = m_Xhandler.getAnyElement();
         if (!elem)
         {
-			//Chinthana:check the peek is called or not
-			if(!m_bPeeked) 
-			{
-				bCanParseMore = m_pParser->parseNext(m_ScanToken);
-			}
-			else
-			{
-				m_bPeeked = false;
-				bCanParseMore = true;
-			}
-			elem = m_Xhandler.getAnyElement();
-			
-			//27/04/2005
+            //Chinthana:check the peek is called or not
+            if(!m_bPeeked) 
+                bCanParseMore = m_pParser->parseNext(m_ScanToken);
+            else
+            {
+                m_bPeeked = false;
+                bCanParseMore = true;
+            }
+            elem = m_Xhandler.getAnyElement();
         }
         if (elem)
         {
@@ -162,106 +152,100 @@
                 continue;
             }
 
-			if( m_bPeeked )
-				m_bPeeked = false;
+            if( m_bPeeked )
+                m_bPeeked = false;
             
-			return elem;
+            return elem;
         }
-        else if (AXIS_FAIL == m_Xhandler.getStatus()) return NULL;
-        else if (!bCanParseMore) return NULL;
+        else if (AXIS_FAIL == m_Xhandler.getStatus()) 
+            return NULL;
+        else if (!bCanParseMore) 
+            return NULL;
     }
 }
-//Chinthana:New method which peek a head next element 
-//Here always Peek() will call after the first pase done
+// New method which peek a head next element 
+// Here always Peek() will call after the first pase done
 const char* XMLParserXerces::peek()
 {
     if (!m_bPeeked)
     {
-    	if(!m_bFirstParsed)
+        if(!m_bFirstParsed)
         {
-    		m_pParser->parseFirst(*m_pInputSource, m_ScanToken);
+            m_pParser->parseFirst(*m_pInputSource, m_ScanToken);
             m_bFirstParsed = true;
         }
-    	 
-    	bool bCanParseMore = true;
-    	
-    	m_Xhandler.freeElement();
-    	bCanParseMore = m_pParser->parseNext(m_ScanToken);
-    	AnyElement* elem = m_Xhandler.getAnyElement();
-    	while (CHARACTER_ELEMENT == elem->m_type) // we never peek for char data
-    											  //hence this is a white space
+         
+        bool bCanParseMore = true;
+        
+        m_Xhandler.freeElement();
+        bCanParseMore = m_pParser->parseNext(m_ScanToken);
+        AnyElement* elem = m_Xhandler.getAnyElement();
+        while (CHARACTER_ELEMENT == elem->m_type) // we never peek for char data
+                                                  //hence this is a white space
         { /* ignorable white space */
             m_Xhandler.freeElement();
-    		bCanParseMore = m_pParser->parseNext(m_ScanToken);
-    		elem = m_Xhandler.getAnyElement();
+            bCanParseMore = m_pParser->parseNext(m_ScanToken);
+            elem = m_Xhandler.getAnyElement();
          }
     }
 
-	m_bPeeked = true;
-	
-	const XML_NODE_TYPE type = m_Xhandler.peekNextElementType();
-	if(type != END_ELEMENT && type != END_PREFIX && type != UNKNOWN)
-    {
-		const char* name = m_Xhandler.peekNextElementName();
-		return name;
-	}
-	else
-	{
-		return "";
-	}
-
-	
+    m_bPeeked = true;
+    
+    const XML_NODE_TYPE type = m_Xhandler.peekNextElementType();
+    if(type != END_ELEMENT && type != END_PREFIX && type != UNKNOWN)
+    {
+        const char* name = m_Xhandler.peekNextElementName();
+        return name;
+    }
+    else
+        return "";
 }
-//27/04/2005
 
 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_bFirstParsed = true;
-        }
+    
+    // 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_bFirstParsed = true;
+    }
 
-		if(!m_bPeeked) 
-		{
-			m_Xhandler.freeElement();
-		}
+    if(!m_bPeeked) 
+        m_Xhandler.freeElement();
 
-		while (true)
+    while (true)
+    {
+        AnyElement* elem = m_Xhandler.getAnyElement();
+        if (!elem)
         {
-            AnyElement* elem = m_Xhandler.getAnyElement();
-            if (!elem)
+            if(!m_bPeeked) 
+                bCanParseMore = m_pParser->parseNext(m_ScanToken);
+            else
             {
-                if(!m_bPeeked) 
-				{
-					bCanParseMore = m_pParser->parseNext(m_ScanToken);
-				}
-				else
-				{
-					m_bPeeked = false;
-					bCanParseMore = true;
-				}
-
-                elem = m_Xhandler.getAnyElement();
+                m_bPeeked = false;
+                bCanParseMore = true;
             }
-            if (elem)
-            {
-				m_Xhandler.setGetPrefixMappings(false);
 
-				if( m_bPeeked )
-					m_bPeeked = false;
+            elem = m_Xhandler.getAnyElement();
+        }
+        if (elem)
+        {
+            m_Xhandler.setGetPrefixMappings(false);
 
-				return elem;
-            }
-            else if (AXIS_FAIL == m_Xhandler.getStatus()) return NULL;
-            else if (!bCanParseMore) return NULL;
+            if( m_bPeeked )
+                m_bPeeked = false;
+
+            return elem;
         }
+        else if (AXIS_FAIL == m_Xhandler.getStatus()) 
+            return NULL;
+        else if (!bCanParseMore) 
+            return NULL;
+    }
 }
 
 const XML_Ch* XMLParserXerces::getPrefix4NS(const XML_Ch* pcNS)

Modified: webservices/axis/trunk/c/src/xml/xerces/XMLParserXerces.h
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/xml/xerces/XMLParserXerces.h?rev=382097&r1=382096&r2=382097&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/xml/xerces/XMLParserXerces.h (original)
+++ webservices/axis/trunk/c/src/xml/xerces/XMLParserXerces.h Wed Mar  1 09:42:39 2006
@@ -36,11 +36,8 @@
 #include <xercesc/framework/XMLPScanToken.hpp>
 #include "SoapInputSource.h"
 #include "../AxisParseException.h"
-/*
-Try this again at some point in the future.  At the moment it works on
-Windows, but Linux as a problem...
+
 #include "../../transport/axis3/HTTPTransportException.hpp"
-*/
 
 XERCES_CPP_NAMESPACE_USE
 
@@ -54,9 +51,9 @@
     int setInputStream(AxisIOStream* pInputStream);
     const XML_Ch* getNS4Prefix(const XML_Ch* pcPrefix);
     int getStatus();
-    const AnyElement* next(bool bIsCharData=false);//Chinthana:change to accept "all" construct
27/04/2005
+    const AnyElement* next(bool bIsCharData=false);
     const AnyElement* anyNext();
-	const char* peek(); //Chinthana:Add the method to peek head and find the next element 27/04/2005.
+    const char* peek();
     const XML_Ch* getPrefix4NS(const XML_Ch* pcNS);
 
 private:
@@ -65,9 +62,7 @@
     XercesHandler m_Xhandler;
     bool m_bFirstParsed;
     SoapInputSource* m_pInputSource;
-	bool m_bPeeked;
-
-
+    bool m_bPeeked;
 };
 
 #endif



Mime
View raw message