susantha    2003/07/17 23:16:05

  Modified:    c/src/common BasicTypeSerializer.cpp
  Log:
  converting special XML charactors to entity references when serializing is done
  
  Revision  Changes    Path
  1.5       +64 -1     xml-axis/c/src/common/BasicTypeSerializer.cpp
  
  Index: BasicTypeSerializer.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/common/BasicTypeSerializer.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BasicTypeSerializer.cpp   18 Jul 2003 05:29:10 -0000      1.4
  +++ BasicTypeSerializer.cpp   18 Jul 2003 06:16:05 -0000      1.5
  @@ -73,6 +73,7 @@
   char BasicTypeSerializer::m_Buf[64];
   XSDTYPE BasicTypeSerializer::m_Type;
   string BasicTypeSerializer::m_sSZ = "";
  +string BasicTypeSerializer::m_AuxStr = "";
   
   BasicTypeSerializer::BasicTypeSerializer()
   {
  @@ -142,5 +143,67 @@
   
   string& BasicTypeSerializer::GetEntityReferenced(const string &str)
   {
  -     return str;
  +     int pos;
  +     //replace "&" with "&" if any
  +     m_AuxStr = str;
  +     pos = 0;
  +     while (true)
  +     {
  +             pos = m_AuxStr.find('&', pos);
  +             if (pos < m_AuxStr.length())
  +             {
  +                     m_AuxStr = m_AuxStr.replace(pos, 1, "&amp;");
  +             }
  +             else break;
  +             pos++;
  +     }
  +     //replace "<" with "&lt;" if any
  +     pos = 0;
  +     while (true)
  +     {
  +             pos = m_AuxStr.find('<', pos);
  +             if (pos < m_AuxStr.length())
  +             {
  +                     m_AuxStr = m_AuxStr.replace(pos, 1, "&lt;");
  +             }
  +             else break;
  +             pos++;
  +     }
  +     //replace ">" with "&gt;" if any
  +     pos = 0;
  +     while (true)
  +     {
  +             pos = m_AuxStr.find('>', pos);
  +             if (pos < m_AuxStr.length())
  +             {
  +                     m_AuxStr = m_AuxStr.replace(pos, 1, "&gt;");
  +             }
  +             else break;
  +             pos++;
  +     }
  +     //replace "'" with "&apos;" if any
  +     pos = 0;
  +     while (true)
  +     {
  +             pos = m_AuxStr.find('\'', pos);
  +             if (pos < m_AuxStr.length())
  +             {
  +                     m_AuxStr = m_AuxStr.replace(pos, 1, "&apos;");
  +             }
  +             else break;
  +             pos++;
  +     }
  +     //replace """ with "&quot;" if any
  +     pos = 0;
  +     while (true)
  +     {
  +             pos = m_AuxStr.find('"', pos);
  +             if (pos < m_AuxStr.length())
  +             {
  +                     m_AuxStr = m_AuxStr.replace(pos, 1, "&quot;");
  +             }
  +             else break;
  +             pos++;
  +     }
  +     return m_AuxStr;
   }
  
  
  

Reply via email to