Hi Pranav,
XMLString::transcode should throw an exception only if Initialize has not been called, or if the char* buffer contains invalid characters for the current locale; but as you state that Initialize has been called, and being "LS" a normal ASCII string, the only thing you can do now is catching the exception and discovering the reason for the error.

Alberto

At 11.41 30/06/2007 +0530, Pranav, Savkur wrote:

 Hello Alberto,
        Can you please let me know if there is a problem as below with
the transcode function of Xerces

Regards,
Pranav

-----Original Message-----
From: Pranav, Savkur
Sent: Monday, June 25, 2007 5:44 PM
To: ext Alberto Massari
Cc: [email protected]
Subject: RE: FW: XMLString::transcode throws exception

 hello Alberto,
        Even calling XMLPlatformUtils::Initialize at the main thread
does not solve the problem.
Now I'm calling this in my CServiceModule::Run function which means its
getting called only once but
XERCES_CPP_NAMESPACE::XMLString::transcode("LS", tempStr, 3999); throws
an exception

Is this problem known?

Regards.
Pranav

-----Original Message-----
From: ext Alberto Massari [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 12, 2007 8:06 PM
To: Pranav, Savkur
Cc: [email protected]
Subject: RE: FW: XMLString::transcode throws exception

So now it turns out that this method is actually one of multiple
threads?
XMLPlatformUtils::Initialize needs to be called only once at the main
thread

Alberto

At 19.56 12/06/2007 +0530, Pranav, Savkur wrote:
>Yes I have called that just before the tempstr
>
>XERCES_CPP_NAMESPACE::XMLPlatformUtils::Initialize();
>XMLCh tempStr[4000];
>XERCES_CPP_NAMESPACE::XMLString::transcode("LS", tempStr, 3999);
>
>
>Exception appears to be occuring in case this function is called within

>the space of one second. i.e 2 threads executing one after the other in

>this function...
>
>-----Original Message-----
>From: ext Alberto Massari [mailto:[EMAIL PROTECTED]
>Sent: Tuesday, June 12, 2007 7:54 PM
>To: Pranav, Savkur
>Cc: [email protected]
>Subject: RE: FW: XMLString::transcode throws exception
>
>Oh, well, this is a whole different issue.... have you called
>XMLPlatformUtils::Initialize?
>
>Alberto
>
>At 18.05 12/06/2007 +0530, Pranav, Savkur wrote:
> >Hello Alberto,
> >
> >         thanks for the reply.
> >
> >But the exception was being raised in the first call to transcode
> >itself:
> >
> >XERCES_CPP_NAMESPACE::XMLString::transcode("LS", tempStr, 3999);
> >
> >i.e much before the createDOMWriter is called on the
> >DOMImplementation object.
> >
> >Will this change solve that problem too?
> >
> >Regards,
> >Pranav
> >
> >
> >-----Original Message-----
> >From: ext Alberto Massari [mailto:[EMAIL PROTECTED]
> >Sent: Tuesday, June 12, 2007 4:56 PM
> >To: Pranav, Savkur
> >Cc: [email protected]
> >Subject: RE: FW: XMLString::transcode throws exception
> >
> >At 16.36 12/06/2007 +0530, Pranav, Savkur wrote:
> > >Hello Alberto,
> > >         My code is like:
> > >
> > >XMLCh tempStr[4000];
> > >  XERCES_CPP_NAMESPACE::XMLString::transcode("LS", tempStr, 3999);
> > >
> > >XERCES_CPP_NAMESPACE::DOMImplementation *impl          =
> > >XERCES_CPP_NAMESPACE::DOMImplementationRegistry::getDOMImplementati
> > >on
> > >(t
> > >e
> > >mpStr);
> > >
> > >pSerializer =
> > >((XERCES_CPP_NAMESPACE::DOMImplementationLS*)impl)->createDOMWriter
> > >()
> > >;
> > >
> > >                 if(0 != pSerializer)
> > >                 {
> > >
> > >
> > >                 XMLCh* pCh =
>pSerializer->writeToString(*p_pDOMNode);
> > >                 char *msg =
> > >XERCES_CPP_NAMESPACE::XMLString::transcode(pCh);
> > >                 CString strRetVal = msg;
> > >                 }
> > >
> > >And in line number 2, I observe generic exception being thrown...
> > >This is once in about 10-15 calls.
> > >
> > >Can you tell me where I can call the SetEncoding API here please
> > >
> > >My intention is to convert a XERCES_CPP_NAMESPACE::DOMNode * into a

> > >Cstring
> >
> >
> >pSerializer =
> >((XERCES_CPP_NAMESPACE::DOMImplementationLS*)impl)->createDOMWriter()
> >;
> >
> >if(0 != pSerializer)
> >{
> >
> >pSerializer->setEncoding(XERCES_CPP_NAMESPACE::XMLUni::fgUTF8Encoding
> >pSerializer->St
> >pSerializer->r
> >ing);
> >          XERCES_CPP_NAMESPACE::MemBufFormatTarget target;
> >          pSerializer->writeNode(&target, *p_pDOMNode);
> >          strRetVal = (const char*)target.getRawBuffer(); }
> >
> >Alberto
> >
> >
> >
> > >Regards,
> > >Pranav
> > >-----Original Message-----
> > >From: ext Alberto Massari [mailto:[EMAIL PROTECTED]
> > >Sent: Monday, June 04, 2007 1:32 PM
> > >To: Pranav, Savkur
> > >Cc: [email protected]
> > >Subject: RE: FW: XMLString::transcode throws exception
> > >
> > >At 12.44 04/06/2007 +0530, Pranav, Savkur wrote:
> > > >Hello Alberto,
> > > >         thanks for the reply.
> > > >Do I use UTF-8 as the parameter when I call the setEncoding API?
> > >
> > >Yes, use L"UTF-8"
> > >
> > >Alberto
> > >
> > >
> > > >Regards,
> > > >Pranav
> > > >
> > > >-----Original Message-----
> > > >From: ext Alberto Massari [mailto:[EMAIL PROTECTED]
> > > >Sent: Saturday, June 02, 2007 12:26 AM
> > > >To: Pranav, Savkur
> > > >Cc: [email protected]
> > > >Subject: RE: FW: XMLString::transcode throws exception
> > > >
> > > >At 18.55 01/06/2007 +0530, Pranav, Savkur wrote:
> > > > >Hello Alberto,
> > > > >
> > > > >         thanks for the info!
> > > > >The CSTring is returned from the function and parsed at a later

> > > > >point
> > >
> > > > >in time again...
> > > > >Do you see any probs with that?
> > > >
> > > >If you are going to parse the CString, use UTF-8, at least it
> > > >will not change the XML to include character references.
> > > >
> > > >Alberto
> > > >
> > > >
> > > > >Regards,
> > > > >Pranav
> > > > >
> > > > >-----Original Message-----
> > > > >From: ext Alberto Massari [mailto:[EMAIL PROTECTED]
> > > > >Sent: Friday, June 01, 2007 6:11 PM
> > > > >To: Pranav, Savkur
> > > > >Cc: [email protected]
> > > > >Subject: RE: FW: XMLString::transcode throws exception
> > > > >
> > > > >At 18.00 01/06/2007 +0530, Pranav, Savkur wrote:
> > > > > >Hello Alberto,
> > > > > >         thank you for the reply.
> > > > > >What is the parameter that must be passed to this setEncoding
> > > >function?
> > > > >
> > > > >I would try with ISO-8859-1, but it depends on what you are
> > > > >planning to
> > > >
> > > > >do later with that CString....
> > > > >
> > > > >Alberto
> > > > >
> > > > > >Regards,
> > > > > >Pranav
> > > > > >
> > > > > >-----Original Message-----
> > > > > >From: ext Alberto Massari [mailto:[EMAIL PROTECTED]
> > > > > >Sent: Friday, June 01, 2007 5:52 PM
> > > > > >To: Pranav, Savkur
> > > > > >Cc: [email protected]
> > > > > >Subject: Re: FW: XMLString::transcode throws exception
> > > > > >
> > > > > >Hi Pranav,
> > > > > >I haven't seen this message on the c-users mailing list (but
> > > > > >I am
> >
> > > > > >cc-ing it now).
> > > > > >The reason for an exception in XMLString::transcode could be
> > > > > >that
> >
> > > > > >the
> > > >
> > > > > >string cannot be converted into the current locale; have you
> > > > > >tried using DOMWriter::setEncoding to force your desired
> > > > > >final encoding, then
> > > > >
> > > > > >invoking DOMWriter::writeNode using a MemBufFormatTarget as
> > > > >destination?
> > > > > >
> > > > > >Alberto
> > > > > >
> > > > > >At 17.31 01/06/2007 +0530, Pranav, Savkur wrote:
> > > > > >
> > > > > > >  Hello Alberto,
> > > > > > >
> > > > > > >         I had mailed this to the mailing list but its
> > > > > > > probably
> >
> > > > > > > not
> > > > > >sent.
> > > > > > >Can you pls help me with this
> > > > > > >
> > > > > > >Regards,
> > > > > > >Pranav
> > > > > > >
> > > > > > >         We're using Xerces for C++
> > > > > > >
> > > > > > >         Our code is like:
> > > > > > >
> > > > > > >  XMLCh tempStr[4000];
> > > > > > >  XERCES_CPP_NAMESPACE::XMLString::transcode("LS", tempStr,

> > > > > > > 3999);
> > > > > > >
> > > > > > >XERCES_CPP_NAMESPACE::DOMImplementation *impl          =
> > > > > > >XERCES_CPP_NAMESPACE::DOMImplementationRegistry::getDOMImpl
> > > > > > >em
> > > > > > >en
> > > > > > >ta
> > > > > > >ti
> > > > > > >on
> > > > > > >(t
> > > > > > >e
> > > > > > >mpStr);
> > > > > > >
> > > > > > >pSerializer =
> > > > > > >((XERCES_CPP_NAMESPACE::DOMImplementationLS*)impl)->createD
> > > > > > >OM
> > > > > > >Wr
> > > > > > >it
> > > > > > >er
> > > > > > >()
> > > > > > >;
> > > > > > >
> > > > > > >                 if(0 != pSerializer)
> > > > > > >                 {
> > > > > > >
> > > > > > >
> > > > > > >                 XMLCh* pCh =
> > > > >pSerializer->writeToString(*p_pDOMNode);
> > > > > > >                 char *msg =
> > > > > > >XERCES_CPP_NAMESPACE::XMLString::transcode(pCh);
> > > > > > >                 CString strRetVal = msg;
> > > > > > >                 }
> > > > > > >
> > > > > > >
> > > > > > >But the call to transcode in line 2 is causing a generic
> > >exception.
> > > > > > >Can you pls tell me what the reason could be? If the code
> > > > > > >is wrong or
> > > > >
> > > > > > >something?
> > > > > > >This seems to be an intermittent behavior and does not
> > > > > > >happen
>
> > > > > > >always
> > > > > > >
> > > > > > >I have also tried this with:
> > > > > > >
> > > > > > >XERCES_CPP_NAMESPACE::DOMImplementation* impl =
> > > > > > >XERCES_CPP_NAMESPACE::DOMImplementationRegistry::getDOMImpl
> > > > > > >em
> > > > > > >en
> > > > > > >ta ti on (X E
> > > > > > >RCES_CPP_NAMESPACE::XMLString::transcode("Core"));
> > > > > > >
> > > > > > >pSerializer =
> > > > > > >((XERCES_CPP_NAMESPACE::DOMImplementationLS*)impl)->createD
> > > > > > >OM
> > > > > > >Wr
> > > > > > >it
> > > > > > >er
> > > > > > >()
> > > > > > >;
> > > > > > >
> > > > > > >if(0 != pSerializer)
> > > > > > >         {
> > > > > > >
> > > > > > >
> > > > > > >                 XMLCh* pCh =
> > > > >pSerializer->writeToString(*p_pDOMNode);
> > > > > > >                 char *msg =
> > > > > > >XERCES_CPP_NAMESPACE::XMLString::transcode(pCh);
> > > > > > >                 CString strRetVal = msg;
> > > > > > >         }
> > > > > > >
> > > > > > >With the same result.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >Regards,
> > > > > > >Pranav
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >Disclaimer:
> > > > > > >This e-mail may contain trade secrets or privileged,
> > > > > > >undisclosed or
> > > >
> > > > > > >otherwise confidential information. If you have received
> > > > > > >this
>
> > > > > > >e-mail in
> > > > > >
> > > > > > >error, you are hereby notified that any review, copying or
> > > > > > >distribution
> > > > > >
> > > > > > >of it is strictly prohibited. Please inform us immediately
> > > > > > >and destroy the original transmittal. Thank you for your
> >cooperation.
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >Disclaimer:
> > > > > >This e-mail may contain trade secrets or privileged,
> > > > > >undisclosed or
> > >
> > > > > >otherwise confidential information. If you have received this

> > > > > >e-mail in
> > > > >
> > > > > >error, you are hereby notified that any review, copying or
> > > > > >distribution
> > > > >
> > > > > >of it is strictly prohibited. Please inform us immediately
> > > > > >and destroy the original transmittal. Thank you for your
>cooperation.
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >Disclaimer:
> > > > >This e-mail may contain trade secrets or privileged,
> > > > >undisclosed or
> >
> > > > >otherwise confidential information. If you have received this
> > > > >e-mail in
> > > >
> > > > >error, you are hereby notified that any review, copying or
> > > > >distribution
> > > >
> > > > >of it is strictly prohibited. Please inform us immediately and
> > > > >destroy the original transmittal. Thank you for your
cooperation.
> > > >
> > > >
> > > >
> > > >
> > > >Disclaimer:
> > > >This e-mail may contain trade secrets or privileged, undisclosed
> > > >or
>
> > > >otherwise confidential information. If you have received this
> > > >e-mail in
> > >
> > > >error, you are hereby notified that any review, copying or
> > > >distribution
> > >
> > > >of it is strictly prohibited. Please inform us immediately and
> > > >destroy the original transmittal. Thank you for your cooperation.
> > >
> > >
> > >
> > >
> > >Disclaimer:
> > >This e-mail may contain trade secrets or privileged, undisclosed or

> > >otherwise confidential information. If you have received this
> > >e-mail in
> >
> > >error, you are hereby notified that any review, copying or
> > >distribution
> >
> > >of it is strictly prohibited. Please inform us immediately and
> > >destroy the original transmittal. Thank you for your cooperation.
> >
> >
> >
> >
> >Disclaimer:
> >This e-mail may contain trade secrets or privileged, undisclosed or
> >otherwise confidential information. If you have received this e-mail
> >in
>
> >error, you are hereby notified that any review, copying or
> >distribution
>
> >of it is strictly prohibited. Please inform us immediately and
> >destroy the original transmittal. Thank you for your cooperation.
>
>
>
>
>Disclaimer:
>This e-mail may contain trade secrets or privileged, undisclosed or
>otherwise confidential information. If you have received this e-mail in

>error, you are hereby notified that any review, copying or distribution

>of it is strictly prohibited. Please inform us immediately and destroy
>the original transmittal. Thank you for your cooperation.




Disclaimer:
This e-mail may contain trade secrets or privileged, undisclosed or otherwise confidential information. If you have received this e-mail in error, you are hereby notified that any review, copying or distribution of it is strictly prohibited. Please inform us immediately and destroy the original transmittal. Thank you for your cooperation.

Reply via email to