Pranav Savkur wrote:
hi alberto,
       what is the encoding i have to set for the CT2CA object? how do i do
this? please let me know

It all depends on what that class does (and being a user defined class, you should know it): I can only guess it's US-ASCII, i.e.

 memBufIS->setEncoding(XMLUni::fgUSASCIIEncodingString);

But you can get better informations by debugging your application and finding out what exception is being thrown and which part of the parser throws it.

Alberto

regards,
Pranav

On Mon, Dec 1, 2008 at 3:31 PM, Alberto Massari <[EMAIL PROTECTED]>wrote:

Pranav Savkur wrote:

Hello Alberto, thanks for replying.
1.i do hav an XMLException block but the control does not come here
2. i have deleted the wrapper4inputsource now
3.its just that the m_XMLFileName in this case contains the XML string
itself and not really the file name.


If m_XMLFileName contains an XML string, and you really need to convert it
to a different encoding using the CT2CA object, you should invoke
setEncoding on the MemBufInputSource to tell the parser to ignore the
encoding declaration contained in the XML stream.
If this also fails, you should just try running the program in the debugger
and see what exception is really thrown.

Alberto


 Is it correct the way the parameters to MembufInput source are data typed?
We are using VS2005 with Xerces 2.8

On Mon, Dec 1, 2008 at 3:11 PM, Alberto Massari <[EMAIL PROTECTED]
wrote:

A few things that you should check:
1) add a catch handler for XMLException, and check what getMessage says;
using only the catch(...) will not give you any information on the real
cause of the error
2) why are you declaring a Wrapper4InputSource object if you are not
using
it?
3) the MemBufInputSource class must be used to hold an XML fragment, but
you are constructing it around a variable named m_XMLFileName; if this
variable holds a file name (instead of the file content) you should use
LocalFileInputSource

Alberto


Pranav Savkur wrote:



I have one implementation in Xerces C++ 2.8 where in I have this code:




                      try
                      {
                      //const XMLCh* const bufID = NULL;
                      const XMLCh *const bufId = _T("SPVoice");
                      //static const TCHAR* bufID = "SPVoice";
                      CT2CA pszConvertedAnsiString (m_XMLFileName);
                      std::string strStd (pszConvertedAnsiString);

                      const char* pStr = strStd.c_str();
                      //char* TCHAR = StringToChar(m_XMLFileName);

TRACE_INFO("CSPVXMLParserWrapper::CreateDOMTree() converted
StringToChar");

                      MemBufInputSource* memBufIS = new
MemBufInputSource(
                               (const XMLByte *)pStr
                              ,strlen(pStr)
                              , bufId
                              , false
                              );

TRACE_INFO("CSPVXMLParserWrapper::CreateDOMTree() formed
MemBufInputSourceObject Successfully");

                      m_pDOMParser->setDoNamespaces(false);
                      TRACE_INFO("Entering
CSPVXMLParserWrapper::CreateDOMTree() SetDoNamespace set to false");

                      Wrapper4InputSource wrap(memBufIS, false);

                      m_pDOMParser->parse(*memBufIS);
                      }
                      catch (...)
                      {
                      cstrTraceMsg.Format(_T("ERROR: Internal Error
- Unexpected exception during parsing: %s "), m_XMLFileName);

                      TRACE_ERROR(CLString(cstrTraceMsg),ERR_FAILURE);
                      sifRetCode = ERR_FAILURE;
                      m_strErrorString = _T("Generic Exception
During Parsing the input XML File.Please check if the XML input
conforms to the schema");

                      }

At the m_pDOMParser->parse(*memBufIS); The control goes into the catch
block.
Can you point out any probs in the code? Without the
Wrapper4InputSource wrap(memBufIS, false);, this code was working in
Xerces 2.2 of C++








Reply via email to