[xsd-users] xml_schema::Date and xml_schema::Time are wrong serialized on UNICODE files

Constantin Iacobescu sir.costy at gmail.com
Fri Nov 19 04:52:44 EST 2010


Hello everyone,

I am try to use a XSD binding of LandXML to read and write thous files.
But I have just get in trouble on trying to serialize the xml, because the
date and time it is written wrong in file.

The command line is this:
xsd cxx-tree --generate-serialization --generate-polymorphic
--generate-doxygen --generate-wildcard --generate-ostream --root-element-all
--char-type wchar_t --type-naming java --function-naming java
--namespace-map
http://www.landxml.org/schema/LandXML-1.2=LandXML_12LandXML-1.2.xsd

So I added the --char-type wchar_t for unicode support.

The code I use is this:

XMLPlatformUtils::Initialize ();

LocalFileFormatTarget formatTarget (fileName.c_str());

xml_schema::Date _date(2010, 12, 24);
xml_schema::Time _time( 14, 35, 42);

std::auto_ptr<LandXML> objLandXML ( new LandXML(_date, _time, L"1.2"));

xml_schema::NamespaceInfomap infoMap;

infoMap[L""].name    = L"http://www.landxml.org/schema/LandXML-1.2";
infoMap[L""].schema = L"
http://www.landxml.org/schema/LandXML-1.2/LandXML-1.2.xsd";

serializeLandXML(formatTarget,
                        *objLandXML,
                        infoMap,
                        L"UTF-8",
                        xml_schema::Flags::dont_initialize);

XMLPlatformUtils::Terminate ();

I use LocalFileFormatTarget xercesc function because te name of the file may
be unicode too. But think this is other thing.

And what I get in to the file it is this:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<LandXML xmlns="http://www.landxml.org/schema/LandXML-1.2" date="2010-0-0"
time="0:0#:42" version="1.2" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.landxml.org/schema/LandXML-1.2
http://www.landxml.org/schema/LandXML-1.2/LandXML-1.2.xsd">


And all the places I want to use the xml_schema::Date or xml_schema::Time
gaves me the same problem.
A bit of help will be appreciated.

Best Regards,
Constantin Iacobescu

-- 
Constantin Iacobescu


More information about the xsd-users mailing list