axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From di...@apache.org
Subject cvs commit: ws-axis/c/src/xml/xml4c ParserLoader.cpp SoapBinInputStream.cpp SoapBinInputStream.h SoapInputSource.cpp SoapInputSource.h XMLParserXerces.cpp XMLParserXerces.h XercesHandler.cpp XercesHandler.h
Date Tue, 12 Oct 2004 10:48:31 GMT
dicka       2004/10/12 03:48:31

  Added:       c/src/xml/xml4c ParserLoader.cpp SoapBinInputStream.cpp
                        SoapBinInputStream.h SoapInputSource.cpp
                        SoapInputSource.h XMLParserXerces.cpp
                        XMLParserXerces.h XercesHandler.cpp XercesHandler.h
  Log:
  Provision of XML4C XMLParser - This is basically the Xerces Parser abstraction layer
  
  Submitted by: Adrian Dick
  
  Revision  Changes    Path
  1.1                  ws-axis/c/src/xml/xml4c/ParserLoader.cpp
  
  Index: ParserLoader.cpp
  ===================================================================
  /*
   *   Copyright 2003-2004 The Apache Software Foundation.
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *   limitations under the License.
   */
  
  /*
   * @author Susantha Kumara (skumara@virtusa.com)
   *
   */
  
  #include "XMLParserXerces.h"
  #include <xercesc/util/PlatformUtils.hpp>
  
  extern "C" {
  STORAGE_CLASS_INFO
  int CreateInstance(XMLParser **inst)
  {
  	/* TODO : Following initialization should be done within a function
  	          called by the library loader at loading time */
      XMLPlatformUtils::Initialize();
  	*inst = new XMLParserXerces();
  	if (*inst)
  	{
  		return AXIS_SUCCESS;
  	}
  	return AXIS_FAIL;
  }
  STORAGE_CLASS_INFO 
  int DestroyInstance(XMLParser *inst)
  {
  	if (inst)
  	{
  		delete inst;
  	/* TODO : Following uninitialization should be done within a function
  	          called by the library loader at unloading time */
  		XMLPlatformUtils::Terminate ();
  		return AXIS_SUCCESS;
  	}
  	return AXIS_FAIL;
  }
  }
  
  
  
  1.1                  ws-axis/c/src/xml/xml4c/SoapBinInputStream.cpp
  
  Index: SoapBinInputStream.cpp
  ===================================================================
  /*
   *   Copyright 2003-2004 The Apache Software Foundation.
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *   limitations under the License.
   */
  
  /* SoapBinInputStream.cpp: implementation of the SoapBinInputStream class. */
  
  
  #include "SoapBinInputStream.h"
  
  SoapBinInputStream::SoapBinInputStream(AxisIOStream* pInputStream)
  {
      m_pInputStream = pInputStream;
      m_nByteCount = 0;
  }
  
  SoapBinInputStream::~SoapBinInputStream()
  {
  
  }
  
  /*
   * I dont really understand the use of this function
   */
  unsigned int SoapBinInputStream::curPos() const
  {
      return m_nByteCount;
  }
  
  unsigned int SoapBinInputStream::readBytes(XMLByte* const pcToFill,
                                             const unsigned int iMaxToRead)
  {
      int iRead = iMaxToRead;
  	m_pInputStream->getBytes((char*)pcToFill, &iRead);
  	m_nByteCount += iRead;
      return iRead;
  }
  
  
  
  1.1                  ws-axis/c/src/xml/xml4c/SoapBinInputStream.h
  
  Index: SoapBinInputStream.h
  ===================================================================
  /*
   *   Copyright 2003-2004 The Apache Software Foundation.
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *   limitations under the License.
   */
  
  /* SoapBinInputStream.h: interface for the SoapBinInputStream class. */
  
  #if !defined(AXIS_SOAPBININPUTSTREAM_H__OF_AXIS_INCLUDED_)
  #define AXIS_SOAPBININPUTSTREAM_H__OF_AXIS_INCLUDED_
  
  #include <xercesc/util/BinInputStream.hpp>
  #include <axis/server/Packet.h>
  #include "../../transport/SOAPTransport.h"
  
  XERCES_CPP_NAMESPACE_USE
  AXIS_CPP_NAMESPACE_USE
  
  class SoapBinInputStream : public BinInputStream
  {
  public:
      SoapBinInputStream(AxisIOStream* pInputStream);
      virtual ~SoapBinInputStream();
      unsigned int curPos() const;
      unsigned int readBytes(XMLByte* const pcToFill, const unsigned int iMaxToRead);
  private:
      unsigned int m_nByteCount;
      AxisIOStream* m_pInputStream;
  };
  
  #endif
  
  
  
  1.1                  ws-axis/c/src/xml/xml4c/SoapInputSource.cpp
  
  Index: SoapInputSource.cpp
  ===================================================================
  /*
   *   Copyright 2003-2004 The Apache Software Foundation.
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *   limitations under the License.
   */
  
  /* SoapInputSource.cpp: implementation of the SoapInputSource class. */
  
  #include "SoapInputSource.h"
  
  SoapInputSource::SoapInputSource(AxisIOStream* pInputStream)
  {
      m_pInputStream = new SoapBinInputStream(pInputStream);
  }
  
  SoapInputSource::~SoapInputSource()
  {
  	/* do not delete the m_pInputStream. See Xerces documentation */
  }
  
  BinInputStream* SoapInputSource::makeStream() const
  {
      return m_pInputStream;
  }
  
  
  
  1.1                  ws-axis/c/src/xml/xml4c/SoapInputSource.h
  
  Index: SoapInputSource.h
  ===================================================================
  /*
   *   Copyright 2003-2004 The Apache Software Foundation.
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *   limitations under the License.
   */
  
  /*
   *    @author sanjaya singharage (sanjayas@opensource.lk)
   */
  
  #if !defined(AXIS_SOAPINPUTSOURCE_H__OF_AXIS_INCLUDED_)
  #define AXIS_SOAPINPUTSOURCE_H__OF_AXIS_INCLUDED_
  
  #include <xercesc/sax/InputSource.hpp>
  #include "SoapBinInputStream.h"
  
  XERCES_CPP_NAMESPACE_USE
  
  class SoapInputSource : public InputSource  
  {
  private:
      SoapBinInputStream* m_pInputStream;
  public:
      SoapInputSource(AxisIOStream* pInputStream);
      virtual ~SoapInputSource();
      BinInputStream* makeStream() const;
  };
  
  #endif
  
  
  
  1.1                  ws-axis/c/src/xml/xml4c/XMLParserXerces.cpp
  
  Index: XMLParserXerces.cpp
  ===================================================================
  /*
   *   Copyright 2003-2004 The Apache Software Foundation.
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *   limitations under the License.
   */
  
  /*
   * @author sanjaya singharage (sanjayas@opensource.lk)
   */
  
  
  #ifdef WIN32
  #pragma warning (disable : 4786)
  #pragma warning (disable : 4101)
  #endif
  
  #include "XMLParserXerces.h"
  #include <xercesc/sax2/XMLReaderFactory.hpp>
  
  XERCES_CPP_NAMESPACE_USE
  
  XMLParserXerces::XMLParserXerces()
  {
      m_bFirstParsed = false;
      m_pParser = XMLReaderFactory::createXMLReader();
      m_pInputSource = NULL;
  }
  
  XMLParserXerces::~XMLParserXerces()
  {
      //Samisa - Parser has memory allocated with the last AnyElement parsed; clean that
      m_Xhandler.freeElement();
  
      if(m_pInputSource)
          delete m_pInputSource;
      delete m_pParser;
      
  }
  
  int XMLParserXerces::setInputStream(AxisIOStream* pInputStream)
  {
      m_pInputStream = pInputStream;
      //check if memeory is already allocated for is
      if(m_pInputSource)
          delete m_pInputSource;
      
      m_pInputSource = new SoapInputSource(pInputStream);
  	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;
  }
  
  const XML_Ch* XMLParserXerces::getNS4Prefix(const XML_Ch* prefix)
  {
      return m_Xhandler.ns4Prefix(prefix);
  }
  
  int XMLParserXerces::getStatus()
  {
      return m_Xhandler.getStatus();
  }
  
  const AnyElement* XMLParserXerces::next(bool isCharData)
  {
      bool bCanParseMore = false;
          if(!m_bFirstParsed)
          {
              m_pParser->parseFirst(*m_pInputSource, m_ScanToken);
              m_bFirstParsed = true;
          }
  
          m_Xhandler.freeElement();
          while (true)
          {
              AnyElement* elem = m_Xhandler.getAnyElement();
              if (!elem)
              {
                  bCanParseMore = m_pParser->parseNext(m_ScanToken);
                  elem = m_Xhandler.getAnyElement();
              }
              if (elem)
              {
                  if (!isCharData && (CHARACTER_ELEMENT == elem->m_type))
                  { /* ignorable white space */
                      m_Xhandler.freeElement();
                      continue;
                  }
                  return elem;
              }
              else if (AXIS_FAIL == m_Xhandler.getStatus()) return NULL;
              else if (!bCanParseMore) return NULL;
          }
  }
  
  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;
          }
  
          m_Xhandler.freeElement();
          while (true)
          {
              AnyElement* elem = m_Xhandler.getAnyElement();
              if (!elem)
              {
                  bCanParseMore = m_pParser->parseNext(m_ScanToken);
                  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;
          }
  }
  
  const XML_Ch* XMLParserXerces::getPrefix4NS(const XML_Ch* pcNS)
  {
      return m_Xhandler.prefix4NS(pcNS);
  }
  
  
  
  
  1.1                  ws-axis/c/src/xml/xml4c/XMLParserXerces.h
  
  Index: XMLParserXerces.h
  ===================================================================
  /*
   *   Copyright 2003-2004 The Apache Software Foundation.
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *   limitations under the License.
   */
  
  /*
   *    @author sanjaya singharage (sanjayas@opensource.lk)
   */
  
  
  #ifdef WIN32
  #pragma warning (disable : 4786)
  #endif
  
  #if !defined(__XMLPARSERXERCES_H_OF_AXIS_INCLUDED__)
  #define __XMLPARSERXERCES_H_OF_AXIS_INCLUDED__
  
  #include <axis/server/Packet.h>
  #include "../QName.h"
  #include "../Event.h"
  #include "../XMLParser.h"
  #include "XercesHandler.h"
  
  #include <xercesc/sax2/SAX2XMLReader.hpp>
  #include <xercesc/parsers/SAXParser.hpp>
  #include <xercesc/framework/XMLPScanToken.hpp>
  #include "SoapInputSource.h"
  #include "../AxisParseException.h"
  
  XERCES_CPP_NAMESPACE_USE
  
  class XMLParserXerces: public XMLParser
  {
  
  public:
      XMLParserXerces();
      ~XMLParserXerces();
  
      int setInputStream(AxisIOStream* pInputStream);
      const XML_Ch* getNS4Prefix(const XML_Ch* pcPrefix);
      int getStatus();
      const AnyElement* next(bool bIsCharData=false);
      const AnyElement* anyNext();
      const XML_Ch* getPrefix4NS(const XML_Ch* pcNS);
  
  private:
      SAX2XMLReader* m_pParser;
      XMLPScanToken m_ScanToken;
      XercesHandler m_Xhandler;
      bool m_bFirstParsed;
      SoapInputSource* m_pInputSource;
  
  
  };
  
  #endif
  
  
  
  1.1                  ws-axis/c/src/xml/xml4c/XercesHandler.cpp
  
  Index: XercesHandler.cpp
  ===================================================================
  /*
   *   Copyright 2003-2004 The Apache Software Foundation.
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *   limitations under the License.
   */
  
  /*
   * @author sanjaya singharage (sanjayas@opensource.lk)
   * @author Susantha Kumara (susantha@opensource.lk, skumara@virtusa.com)
   */
  #ifdef WIN32
  #pragma warning (disable : 4786)
  #endif
  
  #include "XercesHandler.h"
  #include <xercesc/sax2/Attributes.hpp>
  #include <stdio.h>
  
  
  XercesHandler::XercesHandler()
  {
      m_nStatus = AXIS_SUCCESS;
  	m_pCurrElement = 0;
      m_pNextElement = (AnyElement*)malloc(sizeof (AnyElement));
  	m_pPrefixMappingElement = (AnyElement*)malloc(sizeof (AnyElement));
      m_bEndElementFollows = false;
      m_pNextElement->m_pchNameOrValue = 0;
      m_pNextElement->m_pchNamespace = 0;
  	m_pNextElement->m_pchAttributes[0] = 0;
      m_pPrefixMappingElement->m_pchNameOrValue = 0;
      m_pPrefixMappingElement->m_pchNamespace = 0;
  	m_pPrefixMappingElement->m_pchAttributes[0] = 0;
  	m_bGetPrefixMappings = false;
  	m_bStartElementWaiting = false;
  }
  
  XercesHandler::~XercesHandler()
  {
  	delete m_pNextElement;
  	delete m_pPrefixMappingElement;
  }
  
  void XercesHandler::startElement(const XMLCh *const uri,const XMLCh *const 
                                   localname,const XMLCh *const qname,
                                   const Attributes &attrs)
  {
      m_pCurrElement = m_pNextElement;
      m_pNextElement->m_type = START_ELEMENT;
      m_pNextElement->m_pchNameOrValue = XMLString::transcode(localname);
      m_pNextElement->m_pchNamespace = XMLString::transcode(uri);
      
      unsigned int len = attrs.getLength();
      unsigned int index;
      unsigned int i = 0;
      for (index = 0; index < len*3; index+=3)
      {    
          m_pNextElement->m_pchAttributes[index] = 
              XMLString::transcode(attrs.getLocalName(i));
          m_pNextElement->m_pchAttributes[index+1] = 
              XMLString::transcode(attrs.getURI(i));
          m_pNextElement->m_pchAttributes[index+2] = 
              XMLString::transcode(attrs.getValue(i));
          i++;
      }
      m_pNextElement->m_pchAttributes[len*3]=NULL;
  }
  
  const XML_Ch* XercesHandler::ns4Prefix(const XML_Ch* prefix)
  {
      if (m_NsStack.find(prefix) != m_NsStack.end())
      {
          return m_NsStack[prefix].c_str();
      }
      return NULL;
  }
  
  const XML_Ch* XercesHandler::prefix4NS(const XML_Ch* pcNS)
  {
      for (map<AxisXMLString, AxisXMLString>::iterator it=m_NsStack.begin();
           it!=m_NsStack.end(); it++)
      {
          if ((*it).second == pcNS)
          {
              return (*it).first.c_str();
          }
      }
      return 0;
  }
      
  void XercesHandler::characters(const XMLCh* const chars, 
                                 const unsigned int length)
  {
      m_pCurrElement = m_pNextElement;
      m_pNextElement->m_type = CHARACTER_ELEMENT;
      m_pNextElement->m_pchNameOrValue = XMLString::transcode(chars);
  }
  void XercesHandler::ignorableWhitespace(const XMLCh* const chars, 
                                          const unsigned int length)
  {}
  void XercesHandler::resetDocument()
  {}
  
  
  void XercesHandler::warning(const SAXParseException& exception)
  {}
  void XercesHandler::error(const SAXParseException& exception)
  {
      m_nStatus = AXIS_FAIL;
  }
  void XercesHandler::fatalError(const SAXParseException& exception)
  {
      m_nStatus = AXIS_FAIL;
  }
  
  void XercesHandler::endElement (const XMLCh *const uri,
                                  const XMLCh *const localname,
                                  const XMLCh *const qname)
  {
      if (m_pCurrElement && (START_ELEMENT == m_pCurrElement->m_type))
      /* it seems that both startElement and endElemen events fired within a
      single parseNext call */
      {
          m_bEndElementFollows = true;
          return;
      }
      m_pCurrElement = m_pNextElement;
      m_pNextElement->m_type = END_ELEMENT;
      m_pNextElement->m_pchNameOrValue = XMLString::transcode(localname);
      m_pNextElement->m_pchNamespace = XMLString::transcode(uri);
      m_pNextElement->m_pchAttributes[0] = NULL;
  }
  
  void XercesHandler::startPrefixMapping(const XMLCh* const prefix,
                                         const XMLCh* const uri)
  {
  	char* pchPrefix = XMLString::transcode(prefix);
  	char* pchUri = XMLString::transcode(uri);
      m_NsStack[pchPrefix] = pchUri;
  	/* Store only if interested in prefix mappings */
  	if (m_bGetPrefixMappings)
  	{
  		m_CurrPrefixMappings[pchPrefix] = pchUri;
  	}
  	else
  	{
  		XMLString::release(&pchPrefix);
  		XMLString::release(&pchUri);
  	}
  }
  
  void XercesHandler::endPrefixMapping(const XMLCh* const prefix)
  {
  	/* we are not interested in end prefix mapping events in any case */
      char* pchPrefix = XMLString::transcode(prefix);
      m_NsStack.erase(pchPrefix);
  	XMLString::release(&pchPrefix);
  }
  
  void XercesHandler::freeElement()
  {
      if (m_pCurrElement)
      {
          if (m_bEndElementFollows)
          /* free only attributes list if available. Next time 
  		 * the same m_pNextElement is freed.
  		 */
          {
              m_bEndElementFollows = false;
              m_pCurrElement->m_type = END_ELEMENT;
  			freeAttributes();
              m_pCurrElement->m_pchAttributes[0] = NULL;
          }
          else
          /* free all inner strings */
          {
  			if (m_pCurrElement->m_pchNameOrValue)
  			{
  				XMLString::release(const_cast<char**>(&(m_pCurrElement->
  					m_pchNameOrValue)));
  				m_pCurrElement->m_pchNameOrValue = 0;
  			}
  			if (m_pCurrElement->m_pchNamespace)
  			{
  				XMLString::release(const_cast<char**>(&(m_pCurrElement->
  					m_pchNamespace)));
  				m_pCurrElement->m_pchNamespace = 0;
  			}
  			freeAttributes();
              m_pCurrElement = 0;
          }
      }
  }
  
  void XercesHandler::freeAttributes()
  {
  	for (int x=0; m_pCurrElement->m_pchAttributes[x]; x+=3)
  	{
  		if (m_pCurrElement->m_pchAttributes[x])
  		{
  			XMLString::release(const_cast<char**>(&(m_pCurrElement->
  				m_pchAttributes[x])));
  			m_pCurrElement->m_pchAttributes[x] = 0;
  			if (m_pCurrElement->m_pchAttributes[x+1])
  				XMLString::release(const_cast<char**>(&(m_pCurrElement->
  				m_pchAttributes[x+1])));
  			if (m_pCurrElement->m_pchAttributes[x+2])
  				XMLString::release(const_cast<char**>(&(m_pCurrElement->
  				m_pchAttributes[x+2])));
  		}
  	}
  }
  
  AnyElement* XercesHandler::getAnyElement()
  {
  	if (m_bGetPrefixMappings)
  	{
  		if (m_CurrPrefixMappings.size() > 0)
  		{
  			map<const AxisChar*, const AxisChar*>::iterator it = 
  				m_CurrPrefixMappings.begin();
  			m_pPrefixMappingElement->m_pchNameOrValue = (*it).first;
  			m_pPrefixMappingElement->m_pchNamespace = (*it).second;
  			m_pPrefixMappingElement->m_type = START_PREFIX;
  			m_CurrPrefixMappings.erase(it);
  			m_pCurrElement = m_pPrefixMappingElement;
  			m_bStartElementWaiting = true;
  		}
  		else if (m_bStartElementWaiting)
  		{
  			m_pCurrElement = m_pNextElement;
  			m_bStartElementWaiting = false;
  		}
  	}
  	return m_pCurrElement;
  }
  
  void XercesHandler::setGetPrefixMappings(bool bValue)
  {
  	m_bGetPrefixMappings = bValue;
  }
  
  
  void XercesHandler::reset()
  {
      m_nStatus = AXIS_SUCCESS;
      m_bEndElementFollows = false;
      m_pCurrElement = m_pNextElement;
  	freeElement();
  	m_pCurrElement = m_pPrefixMappingElement;
  	freeElement();
  	m_bGetPrefixMappings = false;
  	m_bStartElementWaiting = false;	
  	m_pCurrElement = 0;
  	if (m_CurrPrefixMappings.size() > 0)
  	{
  		map<const AxisChar*, const AxisChar*>::iterator it = 
  			m_CurrPrefixMappings.begin();
  		XMLString::release(const_cast<char**>(&((*it).first)));
  		XMLString::release(const_cast<char**>(&((*it).second)));
  		m_CurrPrefixMappings.erase(it);
  	}
  }
  
  
  
  
  
  1.1                  ws-axis/c/src/xml/xml4c/XercesHandler.h
  
  Index: XercesHandler.h
  ===================================================================
  /*
   *   Copyright 2003-2004 The Apache Software Foundation.
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *   limitations under the License.
   */
  
  /*
   *    @author sanjaya singharage (sanjayas@opensource.lk)
   */
  
  #include <xercesc/sax/HandlerBase.hpp>
  #include <xercesc/sax2/DefaultHandler.hpp>
  #include "../AnyElement.h"
  #include <stdlib.h>
  #include <map>
  #include <string>
  #include <axis/server/GDefine.h>
  
  XERCES_CPP_NAMESPACE_USE
  
  using namespace std;
  
  class XercesHandler : public XERCES_CPP_NAMESPACE::DefaultHandler
  {
  public :
      void freeElement();
      inline int getStatus(){return m_nStatus;};
      XercesHandler();
      ~XercesHandler();
      const XML_Ch* ns4Prefix(const XML_Ch* prefix);
      const XML_Ch* prefix4NS(const XML_Ch* pcNS);
      AnyElement* getAnyElement();
  	void setGetPrefixMappings(bool bValue);
  	void reset();
  
  private:
      /* -----------------------------------------------------------------------
       *  Handlers for the SAX DocumentHandler interface
       * -----------------------------------------------------------------------
       */
      void startElement(const XMLCh *const uri,const XMLCh *const localname,
          const XMLCh *const qname,const Attributes &attrs);
      void endElement (const XMLCh *const uri,const XMLCh *const localname,
          const XMLCh *const qname);
      void characters(const XMLCh* const chars, const unsigned int length);
      void startPrefixMapping(const XMLCh* const prefix, const XMLCh* const uri);
      void endPrefixMapping(const XMLCh* const prefix);
      void ignorableWhitespace(const XMLCh* const chars, 
          const unsigned int length);
      void resetDocument();
  
  
      /* -----------------------------------------------------------------------
       *  Implementations of the SAX ErrorHandler interface
       * -----------------------------------------------------------------------
       */
      void warning(const SAXParseException& exception);
      void error(const SAXParseException& exception);
      void fatalError(const SAXParseException& exception);
  
      int m_nStatus;
  	bool m_bEndElementFollows;
      AnyElement* m_pNextElement;
      AnyElement* m_pPrefixMappingElement;
      AnyElement* m_pCurrElement;
      map<AxisXMLString, AxisXMLString> m_NsStack;
  	map<const AxisChar*, const AxisChar*> m_CurrPrefixMappings;
  	bool m_bGetPrefixMappings;
  	bool m_bStartElementWaiting;
  	void freeAttributes();
  };
  
  
  
  

Mime
View raw message