[xsd-users] serialize library objects to ofstream
Schmilinsky, Remsy
Remsy.Schmilinsky at ccra-adrc.gc.ca
Fri Sep 22 10:42:45 EDT 2006
I forgot to include these below line xml_schema::namespace_infomap map;:
map["lib"].name = "http://www.codesynthesis.com/library";
map["lib"].schema = "library.xsd";
so problem resolved !
-----Original Message-----
From: xsd-users-bounces at codesynthesis.com
[mailto:xsd-users-bounces at codesynthesis.com]
Sent: September 22, 2006 10:27 AM
To: xsd-users at codesynthesis.com
Subject: [xsd-users] serialize library objects to ofstream
Hi. I'm trying to combine the library and streaming examples so that I can serialize books into an xml file from memory representation. The code below compiles fine, but when I run it I get "no mapping provided for a namespace".
I compile library.xsd like this:
/usr/local/bin/xsd cxx-tree --generate-inline --generate-ostream --generate-serialization --suppress-parsing --root-element-all library.xsd
please help
std::ofstream ofs;
ofs.exceptions (ios_base::badbit | ios_base::failbit);
ofs.open ("out.xml");
ofs << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl
<< "<lib:catalog>" << endl;
xercesc::XMLPlatformUtils::Initialize ();
xml_schema::namespace_infomap map;
catalog c;
book b(20530902, // ISBN
title("The Elements of Style"), // Title
genre::reference, // Genre
"ES"); // ID
author strunk("William Strunk, Jr.", "1869-07-01");
strunk.died("1946-09-26");
b.author().push_back(strunk);
c.book().push_back(b);
catalog_ (ofs,
c,
map,
"UTF-8",
xml_schema::flags::dont_initialize |
xml_schema::flags::no_xml_declaration);
ofs << "</lib:catalog>" << endl;
xercesc::XMLPlatformUtils::Terminate ();
_______________________________________________
xsd-users mailing list
xsd-users at codesynthesis.com
http://codesynthesis.com/mailman/listinfo/xsd-users
More information about the xsd-users
mailing list