[xsd-users] Questions about Default Value and Debug
lvkun2006 at gmail.com
Tue Apr 8 05:29:25 EDT 2008
Thank you for your patient explanation. But I already add the "--char-type
wchar_t'" option, the string type is converted to wstring,but the stream
insertion operators have not changed.
my compile option
xsd cxx-tree --hxx-suffix .h --cxx-suffix .cpp --char-type wchar_t
--generate-serialization --generate-default-ctor --generate-ostream
--generate-intellisense --cxx-prologue "#include ""stdafx.h""" Base.xsd
2008/4/8, Boris Kolpackov <boris at codesynthesis.com>:
> kun lv <lvkun2006 at gmail.com> writes:
> > I have a large XSD file and generate code from
> > it(with --generate-default-ctor ). I don't set all value for every
> > ,but when I run the program, It throw exception. I want to know if I can
> > find a method allow me not set all value for every element.
> No, there is no such method. The XSD-generated code has no way to
> know what you think the default value should be for every type. I
> suggest that you remove the --generate-default-ctor option. This
> way the generated constructors will force you to specify the
> required values and you won't get any exceptions.
> > And I also want to know if the code generated by xsd could output the
> > log for debugging. The exception infomation is so brief that I can't
> > where cause the error.
> You can use the --generate-ostream option which triggers generation
> of std::ostream insertion operators for every generated type. This
> way you can print the whole object model or any or its fragments
> into a log.
> > In the end, how can i output the structure to wstring. It seems like it
> > only use the stringstream not wstringstream.
> You can instruct the compiler to use 'wchar_t' as the character type
> instead of 'char' in the generate code with the '--char-type wchar_t'
> option. This way the string-based types will all derive from
> std::wstring instead of std::string. The stream insertion operators
> will also use std::wostream instead of std::ostream.
> If you don't want to change the character type in the generated code,
> then you can use the following series of steps (may not work on all
> platforms and/or for all character encodings):
> type& r = ... / object model
> std::ostringstream ostr;
> ostr << r;
> std::wostringstream wostr;
> wostr << ostr.str ().c_str ();
> std::wstring s (wostr.str ());
More information about the xsd-users