[xsd-users] Serialization and extended ascii characters.

jan.noorland at iff.com jan.noorland at iff.com
Fri Jun 6 08:50:13 EDT 2008


Hi Boris,

Thanks for your response.

My code is build with Visual C++ 2003 and the input data is defined as 
char.
The character is a valid ISO Latin-1 character (á = 0xE1).


Exception:      SEHException
StackTrace:
at _CxxThrowException(Void* , _s__ThrowInfo* )
at xsd.cxx.xml.bits.char_transcoder<char>.from(SByte* s, UInt32 length) in 
c:\program files\codesynthesis xsd 3.1\include\xsd\cxx\xml\string.txx:line 
289
at 
xsd.cxx.xml.transcode_to_xmlch<char>(basic_string<char,std::char_traits<char>,std::allocator<char> 
>* s) in c:\program files\codesynthesis xsd 
3.1\include\xsd\cxx\xml\string.ixx:line 117
at xsd.cxx.xml.string.__ctor<char>(string* , 
basic_string<char,std::char_traits<char>,std::allocator<char> >* s) in 
c:\program files\codesynthesis xsd 3.1\include\xsd\cxx\xml\string.hxx:line 
59
at xercesc_2_8.operator<<<char>(DOMElement* e, 
basic_string<char,std::char_traits<char>,std::allocator<char> >* s) in 
c:\program files\codesynthesis xsd 
3.1\include\xsd\cxx\tree\serialization.txx:line 55
at xsd.cxx.tree.bits.insert<char,class xsd::cxx::tree::string<char,class 
xsd::cxx::tree::simple_type<class xsd::cxx::tree::_type> > >(DOMElement* 
e, string<char,xsd::cxx::tree::simple_type<xsd::cxx::tree::_type> >* x) in 
c:\program files\codesynthesis xsd 
3.1\include\xsd\cxx\tree\serialization.txx:line 211
at xsd.cxx.tree.operator<<<char,class xsd::cxx::tree::simple_type<class 
xsd::cxx::tree::_type> >(DOMElement* e, 
string<char,xsd::cxx::tree::simple_type<xsd::cxx::tree::_type> >* x) in 
c:\program files\codesynthesis xsd 
3.1\include\xsd\cxx\tree\serialization.txx:line 231
at xi.npi.<<(DOMElement* e, ProjectDescription* i) in 
d:\data\source\.net\c++\submissiontest\submission.cxx:line 1700
at xi.npi.<<(DOMElement* e, SubmissionType* i) in 
d:\data\source\.net\c++\submissiontest\submission.cxx:line 1586
at xi.npi.Submission(DOMDocument* d, SubmissionType* s, flags 
__unnamed002) in 
d:\data\source\.net\c++\submissiontest\submission.cxx:line 1478
at xi.npi.Submission(auto_ptr<xercesc_2_8::DOMDocument>* , SubmissionType* 
s, namespace_infomap<char>* m, flags f) in 
d:\data\source\.net\c++\submissiontest\submission.cxx:line 1503
at sendSubmissiontoXI(SByte* text1, SByte* text2) in 
d:\data\source\.net\c++\submissiontest\submissiontest.cpp:line 157" 
String*



Does it imply that I need to use the --char-type wchar_t parameter to 
regenerate the XSD code?

Thanks,

Jan.




Boris Kolpackov <boris at codesynthesis.com> 
06/06/2008 02:20 PM

To
jan.noorland at iff.com
cc
xsd-users at codesynthesis.com
Subject
Re: [xsd-users] Serialization and extended ascii characters.






Hi Jan,

jan.noorland at iff.com <jan.noorland at iff.com> writes:

> I'm trying to serialize an object model to XML where one of the string 
> values
> can contain extended ascii characters
> 
> Example:        Instantáneas
> 
> The serialization code throws an exception on the á character.
> 
> Is there a way to solve this?

I tend to think (without knowing which exception is thrown) that 
this is happening because XSD-generated code with character type
'char' expects the text in UTF-8 encoding. So you will need to
make sure that the 'á' character in your string is encoded as
UTF-8 multibyte sequence.

Alternatively, you can try to instruct the generated code to assume
that text is in the local code page by compiling your application
with XSD_USE_LCP macro defined. This approach, however, is not
portable in the sense that you cannot control the local code page
on some platforms (notably, Windows).

For more information see Q 1.2 in the C++/Tree Mapping FAQ:

http://wiki.codesynthesis.com/Tree/FAQ

Boris


* * * * * * * * * *

This communication contains information of International Flavors & 
Fragrances (IFF) and/or its affiliates that may be confidential, 
proprietary, copyrighted and/or legally privileged, and is intended only 
for the addressee. Any copying, dissemination or other use of this 
information by anyone other than the intended recipient is prohibited. If 
you have received this communication in error, please contact the sender 
and delete it from your system.


More information about the xsd-users mailing list