You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ro...@apache.org on 2004/06/14 13:09:28 UTC

cvs commit: ws-axis/c/src/soap SoapSerializer.cpp SoapDeSerializer.cpp

roshan      2004/06/14 04:09:28

  Modified:    c/src/soap SoapSerializer.cpp SoapDeSerializer.cpp
  Log:
  Applied Amila's patch for supporting xsd:any type
  
  Revision  Changes    Path
  1.58      +5 -0      ws-axis/c/src/soap/SoapSerializer.cpp
  
  Index: SoapSerializer.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/SoapSerializer.cpp,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- SoapSerializer.cpp	14 Jun 2004 08:00:46 -0000	1.57
  +++ SoapSerializer.cpp	14 Jun 2004 11:09:28 -0000	1.58
  @@ -885,6 +885,11 @@
   
   int SoapSerializer::serializeAnyObject(AnyType* pAnyObject)
   {
  +    int i;
  +    for (i=0; i<pAnyObject->_size; i++)
  +    {
  +        serialize(pAnyObject->_array[i]);
  +    }
   	return AXIS_SUCCESS;
   }
   
  
  
  
  1.62      +97 -2     ws-axis/c/src/soap/SoapDeSerializer.cpp
  
  Index: SoapDeSerializer.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/SoapDeSerializer.cpp,v
  retrieving revision 1.61
  retrieving revision 1.62
  diff -u -r1.61 -r1.62
  --- SoapDeSerializer.cpp	14 Jun 2004 10:28:38 -0000	1.61
  +++ SoapDeSerializer.cpp	14 Jun 2004 11:09:28 -0000	1.62
  @@ -51,6 +51,7 @@
   #include "../engine/XMLParserFactory.h"
   #include <axis/server/XMLParser.h>
   #include "../xml/QName.h"
  +#include <list>
   
   extern AxisTrace* g_pAT;
   
  @@ -3388,6 +3389,100 @@
   	AnyType* pAny = new AnyType();
   	pAny->_array = 0;
   	pAny->_size = 0;
  -	//TODO
  -	return pAny;
  +
  +    int tagCount = 0;
  +    int lstSize = 0;
  +    
  +    AxisString xmlStr = "";
  +    list<AxisString> lstXML;
  +    
  +    if (!m_pNode) m_pNode = m_pParser->next();
  +    tagCount++;
  +
  +    while ((END_ELEMENT != m_pNode->m_type) || (tagCount >= 0))
  +    {
  +        if (CHARACTER_ELEMENT != m_pNode->m_type)
  +        {
  +            xmlStr = xmlStr + serializeTag(m_pNode);
  +        }
  +        else
  +        {
  +            xmlStr = xmlStr + m_pNode->m_pchNameOrValue;
  +        }
  +
  +        if (tagCount == 0) /* copying the First level element into the list */
  +        {
  +            lstXML.push_back(xmlStr);
  +            xmlStr = "";
  +        }
  +
  +        m_pNode = m_pParser->next();
  +        if (END_ELEMENT == m_pNode->m_type)
  +        {
  +            tagCount--;
  +        }
  +        else if (START_ELEMENT == m_pNode->m_type)
  +        {
  +            tagCount++;
  +        }
  +
  +        lstSize = lstXML.size();
  +        pAny->_array = new char*[lstSize];
  +        pAny->_size = 0;
  +
  +        list<AxisString>::iterator i;  /* Iterator for traversing the list */
  +
  +        for (i=lstXML.begin(); i != lstXML.end(); i++)
  +        {
  +            pAny->_array[pAny->_size] = strdup((*i).c_str());
  +        }
  +    }
  +
  +    return pAny;
  +}
  +
  +
  +AxisString SoapDeSerializer::serializeTag(const AnyElement* node)
  +{
  +    /*
  +       Note that if this is an end tag and since m_pchNameOrValue doesn't give
  +       the "/" sign. So we have to add that sign as well in to the end tag
  +    */
  +
  +    AxisString tmpString;
  +
  +    if (START_ELEMENT == node->m_type)
  +    {
  +        tmpString = "<" + AxisString(node->m_pchNameOrValue);
  +        if (node->m_pchAttributes)
  +        {
  +            int j;
  +
  +            /* structure of the m_pchAttributes[] array is,
  +             * sequence of (local_name, namespace_uri, value)
  +            */
  +            
  +            for (j=0; j<300; j=j+3) /* MAX_NO_OF_ATTRIBUTES = 100 */
  +            {
  +                if (node->m_pchAttributes[j])
  +                {
  +                    tmpString = tmpString + " " + node->m_pchAttributes[j+1];
  +                    tmpString = tmpString + ":" + node->m_pchAttributes[j];
  +                    tmpString = tmpString + "=\"" + node->m_pchAttributes[j+2] + "\"";
  +                }
  +            }
  +        }
  +        if (node->m_pchNamespace)
  +        {
  +            tmpString = tmpString + AxisString(" ") 
  +                + AxisString(node->m_pchNamespace);
  +        }
  +        
  +        tmpString = tmpString + AxisString(">");
  +    }
  +    else if (END_ELEMENT == node->m_type)
  +    {
  +        tmpString = "</" + AxisString(node->m_pchNameOrValue) + ">";
  +    }
  +    return tmpString;
   }