From damon.southworth at uk.bosch.com Thu Dec 8 14:08:00 2016 From: damon.southworth at uk.bosch.com (Southworth Damon (AA-AS/EOS32)) Date: Thu Dec 8 14:08:14 2016 Subject: [xsd-users] XSD Generate Insertion and XSD:AnyAttribute Message-ID: Hi Boris, I think I have come across another bug with the code generated by the xsd-tree compiler with the -generate-insertion option. A new schema that we have included into the project turned out to use XSD:AnyAttribute, for which we had to use the --generate-wildcard option. Whilst the generated code correctly reads the XML files and populates an attribute_set, when it is serialized to a binary format the data is lost. The code generated for XML serialisation is fine... void operator<< (::xercesc::DOMElement& e, const TypeWithAnyAttr& i) { e << static_cast< const ::xml_schema::type& > (i); // any_attribute // for (TypeWithAnyAttr::any_attribute_const_iterator b (i.any_attribute ().begin ()), n (i.any_attribute ().end ()); b != n; ++b) { ::xercesc::DOMAttr* a ( static_cast< ::xercesc::DOMAttr* > ( e.getOwnerDocument ()->importNode ( const_cast< ::xercesc::DOMAttr* > (&(*b)), true))); if (a->getLocalName () == 0) e.setAttributeNode (a); else e.setAttributeNodeNS (a); } } Whereas the binary serialisation does nothing. ::xsd::cxx::tree::ostream< ACE_OutputCDR >& operator<< (::xsd::cxx::tree::ostream< ACE_OutputCDR >& s, const TypeWithAnyAttr &) { return s; } Regards, Damon From bernhard.rapp at student.tugraz.at Fri Dec 9 10:03:24 2016 From: bernhard.rapp at student.tugraz.at (Bernhard Rapp) Date: Fri Dec 9 09:59:08 2016 Subject: [xsd-users] Runtime exception if using istream while string is working Message-ID: <20161209160324.Horde.tmdOAGbmo-ZYSse8Q3XiQPA@webmail.tugraz.at> Hi, I'm new to xsd-users and xml-data-binding. I want to extend the hello example [1] to work with a file or stringstream [2]: std::string xml_file = "path-to-file\\hello.xml"; std::ifstream ifs(xml_file); std::unique_ptr h(hello(ifs, "hello.xml")); Taken from: [1] http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/#2.3 [2] http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#3.5 as you can see, I use --std c++11 ---------------------------------------------------- What problems do I have: If I use the code above and run it, I get: ...exception: xercesc_3_1::RuntimeException at memory location .... ...xsd::cxx::tree::parsing at memory location ... While the example code works like a charm! Does anybody can point me in a direction to look at? ----------------------------------------------------- Additional information: * xsd-4.0.0-i686-windows (just used the zip file...) * MS Visal Studio 2015 (C++11) * Xcerces-c-3.1.4 (I compiled it on my own because I got errors by using the NuGet) * C++/Tree Mapping options: --std C++11 --generate-inline --generate-forward --generate-serialization --gnerate-ostream * precompiler: XERCES_STATIC_LIBRARY (because I got problems with the DLL) * additional dependencies (for now I point directly to the lib, is there maybe a version mismatch which cause the runtime exception?) I really can't find anything which helps me here. Seems like everybody using the xml file name... Thanks a lot in advance, sorry if i forgot something!, Bernhard From boris at codesynthesis.com Fri Dec 9 10:42:19 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Dec 9 10:42:29 2016 Subject: [xsd-users] XSD Generate Insertion and XSD:AnyAttribute In-Reply-To: References: Message-ID: Hi Damon, Southworth Damon (AA-AS/EOS32) writes: > A new schema that we have included into the project turned out to use > XSD:AnyAttribute, for which we had to use the --generate-wildcard option. > Whilst the generated code correctly reads the XML files and populates an > attribute_set, when it is serialized to a binary format the data is lost. XSD does not support binary serialization of wildcard content. If you need it, then you will need to support it in an ad hoc way using type customization. Boris From boris at codesynthesis.com Mon Dec 12 11:10:02 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Dec 12 11:10:12 2016 Subject: [xsd-users] Runtime exception if using istream while string is working In-Reply-To: <20161209160324.Horde.tmdOAGbmo-ZYSse8Q3XiQPA@webmail.tugraz.at> References: <20161209160324.Horde.tmdOAGbmo-ZYSse8Q3XiQPA@webmail.tugraz.at> Message-ID: Hi Bernhard, Bernhard Rapp writes: > If I use the code above and run it, I get: > ...exception: xercesc_3_1::RuntimeException at memory location .... > ...xsd::cxx::tree::parsing at memory location ... > > Does anybody can point me in a direction to look at? Looks like the code throws an exception (xml_schema::parsing). Why don't you catch it, print it, and see what it says? Boris