From dominik.waldispuehl at roche.com Tue Jun 4 03:05:42 2013 From: dominik.waldispuehl at roche.com (Waldispuehl, Dominik) Date: Tue Jun 4 03:21:56 2013 Subject: [xsd-users] CodeSynthesis XSD - LNK1107 compiler error in relation to Xerces Message-ID: <1227FB568E4C834381860D3FCF9C141205AB474601@RBAMSEM710.emea.roche.com> Hello I'm using CodeSynthesis XSD but I'm not very happy about it, from one problem I always go on to the next... Now I've got a problem with the compiling process (Visual Studio with QT-integration, QT-Console-Application that uses generated .cxx / .hxx files), I've added all lib/bin/include directories to the VC++-Directories in Visual Studio 10 and also put the "xerces-c_3D.lib" to the Linker->Additional Dependencies. If I do that, I get unresolved symbols. If I also add the xerces-c_3_1D.dll to the additional Dependencies, the unresolved symbols will go away, but my project will not compile. Now error "LNK1107: invalid or corrupt file: cannot read at 0x2F0 (xerces-c_3_1D.dll)" occurs. Every solution I found on Google was to link the .lib file instead of the .dll file, but that hasn't worked! What have I done wrong? I'm trying now for multiple hours, but I can't spend more 2 hours! Regards Dominik W. From boris at codesynthesis.com Tue Jun 4 03:31:48 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jun 4 03:30:31 2013 Subject: [xsd-users] CodeSynthesis XSD - LNK1107 compiler error in relation to Xerces In-Reply-To: <1227FB568E4C834381860D3FCF9C141205AB474601@RBAMSEM710.emea.roche.com> References: <1227FB568E4C834381860D3FCF9C141205AB474601@RBAMSEM710.emea.roche.com> Message-ID: Hi Dominik, Waldispuehl, Dominik writes: > I'm using CodeSynthesis XSD but I'm not very happy about it, from one > problem I always go on to the next... That's not good. > Now I've got a problem with the compiling process (Visual Studio with > QT-integration, QT-Console-Application that uses generated .cxx / .hxx > files), I've added all lib/bin/include directories to the VC++-Directories > in Visual Studio 10 and also put the "xerces-c_3D.lib" to the > Linker->Additional Dependencies. If I do that, I get unresolved symbols. It is always a good idea to show the exact error message that you are getting. My guess here would be that your project is configured to not treat wchar_t as a native type while Xerces-C++ was built with that option turned on. Can you go to your Project settings and check that (I believe it should be in the C++ Settings, Language tab). > Every solution I found on Google was to link the .lib file instead of > the .dll file, but that hasn't worked! Yes, you should only link the .lib file (called import library). Boris From dominik.waldispuehl at roche.com Tue Jun 4 03:47:44 2013 From: dominik.waldispuehl at roche.com (Waldispuehl, Dominik) Date: Tue Jun 4 04:40:49 2013 Subject: AW: [xsd-users] CodeSynthesis XSD - LNK1107 compiler error in relation to Xerces In-Reply-To: References: <1227FB568E4C834381860D3FCF9C141205AB474601@RBAMSEM710.emea.roche.com> Message-ID: <1227FB568E4C834381860D3FCF9C141205AB47461E@RBAMSEM710.emea.roche.com> Hello Thanks for the fast response. "Treat WChar_t as Built in Type" was set to "No", set it to "Yes(/c:wchar_t)" now and removed the xerces-dll from the additional dependencies. Now I get the unresolved symbols that I've mentioned: "error LNK1120: 31 unresolved externals" followed by these: Error 9 error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned short const * const xercesc_3_1::SchemaSymbols::fgURI_XSI" (__imp_?fgURI_XSI@SchemaSymbols@xercesc_3_1@@2QBGB) ....\MPRawDataSchema.obj Error 7 error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned short const * const xercesc_3_1::SchemaSymbols::fgXSI_NONAMESPACESCHEMALOCACTION" (__imp_?fgXSI_NONAMESPACESCHEMALOCACTION@SchemaSymbols@xercesc_3_1@@2QBGB) ....\MPRawDataSchema.obj Error 8 error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned short const * const xercesc_3_1::SchemaSymbols::fgXSI_SCHEMALOCACTION" (__imp_?fgXSI_SCHEMALOCACTION@SchemaSymbols@xercesc_3_1@@2QBGB) ....\MPRawDataSchema.obj Error 26 error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned short const * const xercesc_3_1::XMLUni::fgDOMComments" (__imp_?fgDOMComments@XMLUni@xercesc_3_1@@2QBGB) ....\MPRawDataSchema.obj Error 25 error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned short const * const xercesc_3_1::XMLUni::fgDOMDatatypeNormalization" (__imp_?fgDOMDatatypeNormalization@XMLUni@xercesc_3_1@@2QBGB) ....\MPRawDataSchema.obj Error 22 error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned short const * const xercesc_3_1::XMLUni::fgDOMElementContentWhitespace" (__imp_?fgDOMElementContentWhitespace@XMLUni@xercesc_3_1@@2QBGB) ....\MPRawDataSchema.obj Error 24 error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned short const * const xercesc_3_1::XMLUni::fgDOMEntities" (__imp_?fgDOMEntities@XMLUni@xercesc_3_1@@2QBGB) ....\MPRawDataSchema.obj Error 13 error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned short const * const xercesc_3_1::XMLUni::fgDOMErrorHandler" (__imp_?fgDOMErrorHandler@XMLUni@xercesc_3_1@@2QBGB) ....\MPRawDataSchema.obj Error 23 error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned short const * const xercesc_3_1::XMLUni::fgDOMNamespaces" (__imp_?fgDOMNamespaces@XMLUni@xercesc_3_1@@2QBGB) ....\MPRawDataSchema.obj Error 21 error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned short const * const xercesc_3_1::XMLUni::fgDOMValidate" (__imp_?fgDOMValidate@XMLUni@xercesc_3_1@@2QBGB) ....\MPRawDataSchema.obj Error 31 error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned short const * const xercesc_3_1::XMLUni::fgDOMWRTDiscardDefaultContent" (__imp_?fgDOMWRTDiscardDefaultContent@XMLUni@xercesc_3_1@@2QBGB) ....\MPRawDataSchema.obj Error 30 error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned short const * const xercesc_3_1::XMLUni::fgDOMWRTFormatPrettyPrint" (__imp_?fgDOMWRTFormatPrettyPrint@XMLUni@xercesc_3_1@@2QBGB) ....\MPRawDataSchema.obj Error 29 error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned short const * const xercesc_3_1::XMLUni::fgDOMXMLDeclaration" (__imp_?fgDOMXMLDeclaration@XMLUni@xercesc_3_1@@2QBGB) ....\MPRawDataSchema.obj Error 18 error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned short const * const xercesc_3_1::XMLUni::fgXercesHandleMultipleImports" (__imp_?fgXercesHandleMultipleImports@XMLUni@xercesc_3_1@@2QBGB) ....\MPRawDataSchema.obj Error 14 error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned short const * const xercesc_3_1::XMLUni::fgXercesLoadSchema" (__imp_?fgXercesLoadSchema@XMLUni@xercesc_3_1@@2QBGB) ....\MPRawDataSchema.obj Error 20 error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned short const * const xercesc_3_1::XMLUni::fgXercesSchema" (__imp_?fgXercesSchema@XMLUni@xercesc_3_1@@2QBGB) ....\MPRawDataSchema.obj Error 15 error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned short const * const xercesc_3_1::XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation" (__imp_?fgXercesSchemaExternalNoNameSpaceSchemaLocation@XMLUni@xercesc_3_1@@2QBGB) ....\MPRawDataSchema.obj Error 16 error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned short const * const xercesc_3_1::XMLUni::fgXercesSchemaExternalSchemaLocation" (__imp_?fgXercesSchemaExternalSchemaLocation@XMLUni@xercesc_3_1@@2QBGB) ....\MPRawDataSchema.obj Error 19 error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned short const * const xercesc_3_1::XMLUni::fgXercesSchemaFullChecking" (__imp_?fgXercesSchemaFullChecking@XMLUni@xercesc_3_1@@2QBGB) ....\MPRawDataSchema.obj Error 17 error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned short const * const xercesc_3_1::XMLUni::fgXercesUserAdoptsDOMDocument" (__imp_?fgXercesUserAdoptsDOMDocument@XMLUni@xercesc_3_1@@2QBGB) ....\MPRawDataSchema.obj Error 11 error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned short const * const xercesc_3_1::XMLUni::fgXMLNSURIName" (__imp_?fgXMLNSURIName@XMLUni@xercesc_3_1@@2QBGB) ....\MPRawDataSchema.obj Error 1 error LNK2001: unresolved external symbol "public: virtual unsigned short const * __thiscall xercesc_3_1::InputSource::getEncoding(void)const " (?getEncoding@InputSource@xercesc_3_1@@UBEPBGXZ) ....\MPRawDataSchema.obj Error 2 error LNK2001: unresolved external symbol "public: virtual unsigned short const * __thiscall xercesc_3_1::InputSource::getPublicId(void)const " (?getPublicId@InputSource@xercesc_3_1@@UBEPBGXZ) ....\MPRawDataSchema.obj Error 3 error LNK2001: unresolved external symbol "public: virtual unsigned short const * __thiscall xercesc_3_1::InputSource::getSystemId(void)const " (?getSystemId@InputSource@xercesc_3_1@@UBEPBGXZ) ....\MPRawDataSchema.obj Error 4 error LNK2001: unresolved external symbol "public: virtual void __thiscall xercesc_3_1::InputSource::setEncoding(unsigned short const * const)" (?setEncoding@InputSource@xercesc_3_1@@UAEXQBG@Z) ....\MPRawDataSchema.obj Error 5 error LNK2001: unresolved external symbol "public: virtual void __thiscall xercesc_3_1::InputSource::setPublicId(unsigned short const * const)" (?setPublicId@InputSource@xercesc_3_1@@UAEXQBG@Z) ....\MPRawDataSchema.obj Error 6 error LNK2001: unresolved external symbol "public: virtual void __thiscall xercesc_3_1::InputSource::setSystemId(unsigned short const * const)" (?setSystemId@InputSource@xercesc_3_1@@UAEXQBG@Z) ....\MPRawDataSchema.obj Error 28 error LNK2019: unresolved external symbol "__declspec(dllimport) protected: __thiscall xercesc_3_1::InputSource::InputSource(unsigned short const * const,class xercesc_3_1::MemoryManager * const)" (__imp_??0InputSource@xercesc_3_1@@IAE@QBGQAVMemoryManager@1@@Z) referenced in function "public: __thiscall xsd::cxx::xml::sax::std_input_source::std_input_source(class std::basic_istream > &,class std::basic_string,class std::allocator > const &)" (??$?0D@std_input_source@sax@xml@cxx@xsd@@QAE@AAV?$basic_istream@DU?$char_traits@D@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@6@@Z) ....\MPRawDataSchema.obj Error 10 error LNK2019: unresolved external symbol "__declspec(dllimport) public: static bool __cdecl xercesc_3_1::XMLString::equals(unsigned short const *,unsigned short const *)" (__imp_?equals@XMLString@xercesc_3_1@@SA_NPBG0@Z) referenced in function "void __cdecl xsd::cxx::xml::dom::clear(class xercesc_3_1::DOMElement &)" (??$clear@D@dom@xml@cxx@xsd@@YAXAAVDOMElement@xercesc_3_1@@@Z) ....\MPRawDataSchema.obj Error 27 error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class xercesc_3_1::DOMImplementation * __cdecl xercesc_3_1::DOMImplementationRegistry::getDOMImplementation(unsigned short const *)" (__imp_?getDOMImplementation@DOMImplementationRegistry@xercesc_3_1@@SAPAVDOMImplementation@2@PBG@Z) referenced in function "struct xsd::cxx::xml::dom::auto_ptr __cdecl xsd::cxx::xml::dom::parse(class std::basic_string,class std::allocator > const &,class xercesc_3_1::DOMErrorHandler &,class xsd::cxx::xml::properties const &,unsigned long)" (??$parse@D@dom@xml@cxx@xsd@@YA?AU?$auto_ptr@VDOMDocument@xercesc_3_1@@@0123@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAVDOMErrorHandler@xercesc_3_1@@ABV?$properties@D@123@K@Z) ....\MPRawDataSchema.obj Error 12 error LNK2019: unresolved external symbol "__declspec(dllimport) public: static unsigned long __cdecl xercesc_3_1::XMLString::stringLen(unsigned short const * const)" (__imp_?stringLen@XMLString@xercesc_3_1@@SAKQBG@Z) referenced in function "class std::basic_string,class std::allocator > __cdecl xsd::cxx::xml::transcode(unsignedshort const *)" (??$transcode@D@xml@cxx@xsd@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PBG@Z) ....\MPRawDataSchema.obj ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Regards Dominik W. -----Urspr?ngliche Nachricht----- Von: Boris Kolpackov [mailto:boris@codesynthesis.com] Gesendet: Dienstag, 4. Juni 2013 09:32 An: Waldispuehl, Dominik {DFRH~Rotkreuz-Tro} Cc: xsd-users@codesynthesis.com Betreff: Re: [xsd-users] CodeSynthesis XSD - LNK1107 compiler error in relation to Xerces Hi Dominik, Waldispuehl, Dominik writes: > I'm using CodeSynthesis XSD but I'm not very happy about it, from one > problem I always go on to the next... That's not good. > Now I've got a problem with the compiling process (Visual Studio with > QT-integration, QT-Console-Application that uses generated .cxx / .hxx > files), I've added all lib/bin/include directories to the > VC++-Directories in Visual Studio 10 and also put the > "xerces-c_3D.lib" to the > Linker->Additional Dependencies. If I do that, I get unresolved symbols. It is always a good idea to show the exact error message that you are getting. My guess here would be that your project is configured to not treat wchar_t as a native type while Xerces-C++ was built with that option turned on. Can you go to your Project settings and check that (I believe it should be in the C++ Settings, Language tab). > Every solution I found on Google was to link the .lib file instead of > the .dll file, but that hasn't worked! Yes, you should only link the .lib file (called import library). Boris From boris at codesynthesis.com Tue Jun 4 04:46:32 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jun 4 04:45:15 2013 Subject: [xsd-users] CodeSynthesis XSD - LNK1107 compiler error in relation to Xerces In-Reply-To: <1227FB568E4C834381860D3FCF9C141205AB47461E@RBAMSEM710.emea.roche.com> References: <1227FB568E4C834381860D3FCF9C141205AB474601@RBAMSEM710.emea.roche.com> <1227FB568E4C834381860D3FCF9C141205AB47461E@RBAMSEM710.emea.roche.com> Message-ID: Hi Dominik, Waldispuehl, Dominik writes: > Error 9 error LNK2001: unresolved external symbol "__declspec(dllimport) > public: static unsigned short const * const xercesc_3_1::SchemaSymbols:: > fgURI_XSI" (__imp_?fgURI_XSI@SchemaSymbols@xercesc_3_1@@2QBGB) > ....\MPRawDataSchema.obj You see that "unsigned short" in the symbol? That's the non-native wchar_t (it is just a typedef for unsigned short). Which means that MPRawDataSchema.obj was (or still is) built with non-native wchar_t option. One thing that you can try is to clean and rebuild all the object files to make sure they were all compiled with the new setting. Boris From hargtholan at gmail.com Tue Jun 11 08:05:11 2013 From: hargtholan at gmail.com (Harg Tholan) Date: Tue Jun 11 08:05:19 2013 Subject: [xsd-users] polymorphism through xs:choice Message-ID: Hi, I have a major doubt regard the use of *idref*. I have an xs:choice (with maxOccurs=unbounded) of different elements which types are derived from the same base type, then I have references to such elements in another point of the schema. The question is, how can I retrieve the actual type of the referenced element? I need to know the actual type because I need to "dynamic cast" to it, but I can not know beforehand. It seems that the use of xs:choice for achieving polymorphism is an anti-pattern, according to this article here: http://www.ibm.com/developerworks/xml/library/ws-tip-xsdchoice/index.html But still, I wonder whether it could be possible to achieve this with XSD Codesynthesis. Code snippets: base type: Then the derived types: [...] As said, a sequence of choice of derived types: Thanks. From boris at codesynthesis.com Tue Jun 11 08:52:28 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jun 11 08:51:11 2013 Subject: [xsd-users] polymorphism through xs:choice In-Reply-To: References: Message-ID: Hi Harg, Harg Tholan writes: > The question is, how can I retrieve the actual type of the referenced > element? I need to know the actual type because I need to "dynamic cast" > to it, but I can not know beforehand. You cannot "retrieve" a C++ type at runtime and dynamic_cast to it. C++ is a compiled, statically-type language. What you can do is discover whether an instance is of one of the types from a predefined (at compile time) set. For example: Base& x = ... // Gen element from the choice. if (DerivedA* a = dynamic_cast (&x)) { // It is DerivedA. } else if (DerivedB* b = dynamic_cast (&x)) { // It is DerivedB. } Other things that you could do are define a virtual function in Base and then implement it in DerivedX (using type customization) or call typeid() on the instance to get, for example, the type name. Boris From Robert.Bielik at gyros.com Tue Jun 11 08:55:51 2013 From: Robert.Bielik at gyros.com (Bielik, Robert) Date: Tue Jun 11 08:55:57 2013 Subject: [xsd-users] polymorphism through xs:choice In-Reply-To: References: Message-ID: <552280EBDB5A804689FADEE5638477190E10D29B@VIEX01SE.ad-gyrosmicro.com> One option would be if there is a possibility to assign a GUID to the generated C++ type, and map that GUID to a casting function. I do the last bit today in my code, but I'd be happy to have the GUID be generated via XSD, so that C# clients can send objects to C++ servers. Would that be simple to do via XSD -> CodeSynthesis ? Regards, /Rob -----Original Message----- From: xsd-users-bounces@codesynthesis.com [mailto:xsd-users-bounces@codesynthesis.com] On Behalf Of Boris Kolpackov Sent: den 11 juni 2013 14:52 To: Harg Tholan Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] polymorphism through xs:choice Hi Harg, Harg Tholan writes: > The question is, how can I retrieve the actual type of the referenced > element? I need to know the actual type because I need to "dynamic cast" > to it, but I can not know beforehand. You cannot "retrieve" a C++ type at runtime and dynamic_cast to it. C++ is a compiled, statically-type language. What you can do is discover whether an instance is of one of the types from a predefined (at compile time) set. For example: Base& x = ... // Gen element from the choice. if (DerivedA* a = dynamic_cast (&x)) { // It is DerivedA. } else if (DerivedB* b = dynamic_cast (&x)) { // It is DerivedB. } Other things that you could do are define a virtual function in Base and then implement it in DerivedX (using type customization) or call typeid() on the instance to get, for example, the type name. Boris From boris at codesynthesis.com Tue Jun 11 09:10:20 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jun 11 09:09:05 2013 Subject: [xsd-users] polymorphism through xs:choice In-Reply-To: <552280EBDB5A804689FADEE5638477190E10D29B@VIEX01SE.ad-gyrosmicro.com> References: <552280EBDB5A804689FADEE5638477190E10D29B@VIEX01SE.ad-gyrosmicro.com> Message-ID: Hi Robert, Bielik, Robert writes: > One option would be if there is a possibility to assign a GUID to the > generated C++ type, and map that GUID to a casting function. But what type will this "casting function" cast to? Maybe some sample code will help me understand what you are trying to achieve here. Boris From hargtholan at gmail.com Tue Jun 11 09:12:40 2013 From: hargtholan at gmail.com (Harg Tholan) Date: Tue Jun 11 09:12:46 2013 Subject: [xsd-users] polymorphism through xs:choice In-Reply-To: References: <552280EBDB5A804689FADEE5638477190E10D29B@VIEX01SE.ad-gyrosmicro.com> Message-ID: Hi, I think that Boris answer serves my purposes of using the "xs:choice polymorphism antipattern". It is actually explained at page 51 of the C++/Tree Mapping Manual. Thank you. 2013/6/11 Boris Kolpackov > Hi Robert, > > Bielik, Robert writes: > > > One option would be if there is a possibility to assign a GUID to the > > generated C++ type, and map that GUID to a casting function. > > But what type will this "casting function" cast to? Maybe some sample > code will help me understand what you are trying to achieve here. > > Boris > From rinil.baxi at hp.com Fri Jun 14 05:15:54 2013 From: rinil.baxi at hp.com (Baxi, Rinil Rushabh) Date: Fri Jun 14 05:16:50 2013 Subject: [xsd-users] HP NonStop Platform Message-ID: <51966E14C3AD0A45B35C9B4D7CD4DD020A6A55AA@G2W2446.americas.hpqcorp.net> Hi All, Is there any option to build this application on HP NonStop Itanium platform? Best Regards, Rinil From boris at codesynthesis.com Wed Jun 19 09:01:43 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jun 19 09:01:51 2013 Subject: [xsd-users] HP NonStop Platform In-Reply-To: <51966E14C3AD0A45B35C9B4D7CD4DD020A6A55AA@G2W2446.americas.hpqcorp.net> References: <51966E14C3AD0A45B35C9B4D7CD4DD020A6A55AA@G2W2446.americas.hpqcorp.net> Message-ID: Hi Rinil, Baxi, Rinil Rushabh writes: > Is there any option to build this application on HP NonStop > Itanium platform? You should be able to build applications that use XSD if you have access to a reasonably-compliant C++98 compiler. You can generate the code on, say, Linux or Windows and then copy it to NonStop and compile it with the C++ compiler there. Building the XSD compiler itself for NonStop it trickier. Right now you would need GCC. However, this will change in the upcoming release of XSD. Boris From rlischner at proteuseng.com Wed Jun 19 17:27:50 2013 From: rlischner at proteuseng.com (Ray Lischner) Date: Thu Jun 20 09:56:44 2013 Subject: [xsd-users] Enumerated types that serialize as numbers Message-ID: We use Code Synthesis most often as an IDL tool, and use serialization a lot. Efficiency is important, but so is clarity of the schemas. We want to use enumerations for clarity, but serializing with the numeric values instead of strings. We can use --custom-type and customize classes easily enough, but we would need to customize each enumerated type individually. That means every developer would need to know how to customize Code Synthesis classes. All the enumerations follow the same pattern, so we shouldn't need to customize each class. We want to isolate the common code, but we need access to the number of literals, the literals array, and the indexes array in a manner that does not require customizing the type. Currently, we define a custom Enumeration class and modified the xsd compiler to recognize any type that ultimately derives from Enumeration, and insert extra code to support our needs. I plan to get away from the magic type by adding an --enumerated-type option to xsd. Requiring the developer to add an option to the xsd command line is much easier than teaching them how to customize a type. Is there a better way? Ray Lischner, Distinguished Member of Technical Staff 133 National Business Pkwy, Ste 150 t. 443.539.3448 Annapolis Junction, MD 20701 c. 410.854.9787 rlischner@proteuseng.com f. 443.539.3370 From boris at codesynthesis.com Thu Jun 20 10:05:50 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jun 20 10:05:59 2013 Subject: [xsd-users] Enumerated types that serialize as numbers In-Reply-To: References: Message-ID: Hi Ray, Ray Lischner writes: > We can use --custom-type and customize classes easily enough, but we > would need to customize each enumerated type individually. You could create a class template that provides the enum semantics that you need and then use it to "wrap" generated enums via type customization. For example: template class numeric_enum: public T { // Customize parsing c-tors to expect numbers. }; // Customize the serialization operators to save enum values as numbers. Then: --custom-type my_enum=numeric_enum/my_enum_base Converting to/from numbers is easy via the underlying enum type (my_enum_base::value). The only thing that you won't be able to do is validate that the number you get in the parsing c-tor is within range. Boris From Rob.Ursem at cmgl.ca Fri Jun 21 19:03:33 2013 From: Rob.Ursem at cmgl.ca (Rob Ursem) Date: Sat Jun 22 02:31:21 2013 Subject: [xsd-users] Issue using proxy for Open Packaging Conventions core-properties schema Message-ID: This is a rather lengthy piece to clarify the context of my issue. I'm trying to implement a library for the Open Packaging Conventions files (newer Office file types). A part of those files is the core properties. This xml file is based on the DublinCore meta data. The schema for the core properties is: Where 'created' is defined as (dcterms.xsd): My xml test document is: 2013-06-21T01:47:29Z rob urn:uuid:079E7602-605A-450B-8C75-E4EE02D6DC33 1.0 The complex elements are the ones in the dc and dcterms namespace. For instance W3CDTF is defined in the schema as: And generated as: class W3CDTF: public ::dcelms::SimpleLiteral { public: // Constructors. // W3CDTF (); W3CDTF (const ::xml_schema::type&); W3CDTF (const ::xercesc::DOMElement& e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); W3CDTF (const W3CDTF& x, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); virtual W3CDTF* _clone (::xml_schema::flags f = 0, ::xml_schema::container* c = 0) const; virtual ~W3CDTF (); }; A partial of my code is: 1 void CoreProperties::LoadFromPart(EpcInputStream part) 2 { 3 ifstream *is = part.GetStream(); 4 5 dcterms::W3CDTF dummyHackToLoadThisTypeSoParsingDoesntFail; 7 8 std::auto_ptr core = parseCoreProperties(*is, xml_schema::flags::dont_validate); 9 10 CT_CoreProperties::created_optional created = core->getCreated(); 11 if (created.present()) 12 { 13 dcterms::W3CDTF p = *created; 14 } I have (had) two main issues parsing this. 1. The initialization of types is somehow skipped by the compiler for types that have not been referenced before. If I don't include line 5 above, the "dcterm:W3CDTF type is not registered and my parsing (on line 8) fails. This seems to be an issue with the compiler (VS2012) rather than with XSD. 2. Once the document is parsed I get a 'created_optional' type (which makes sense). From there on I can get to a dcterms::W3CDTF type (line 13) but I have not been able to get the date value out of that element. Is there something I'm missing or do I need to do things differently? Regards, Rob Ursem From boris at codesynthesis.com Mon Jun 24 08:14:08 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jun 24 08:14:48 2013 Subject: [xsd-users] Issue using proxy for Open Packaging Conventions core-properties schema In-Reply-To: References: Message-ID: Hi Rob, Rob Ursem writes: > > > > > > > > > > > > [...] > > 1. The initialization of types is somehow skipped by the compiler for types > that have not been referenced before. If I don't include line 5 above, > the "dcterm:W3CDTF type is not registered and my parsing (on line 8) > fails. This seems to be an issue with the compiler (VS2012) rather than > with XSD. Are you by any chance packaging the generated code into a static library (.lib)? If so, then this post explains why it won't work out of the box: http://www.codesynthesis.com/pipermail/odb-users/2013-May/001286.html And this followup explains how to make it work with VS: http://www.codesynthesis.com/pipermail/odb-users/2013-May/001289.html > 2. Once the document is parsed I get a 'created_optional' type (which makes > sense). From there on I can get to a dcterms::W3CDTF type (line 13) but I > have not been able to get the date value out of that element. The W3CDTF type is defined as a union of a whole bunch of other types. XSD maps uinons to strings and you will have to figure out which member it it and extract the data yourself. One way to do it would be to customize the generated type. Boris From topoden at gmail.com Mon Jun 24 17:55:33 2013 From: topoden at gmail.com (Denis Toporovsky) Date: Mon Jun 24 17:56:01 2013 Subject: [xsd-users] VS 2012 support Message-ID: Hello, Do you guys plan to support Visual Studio 2012? I do not see it listed on supported platforms page . From boris at codesynthesis.com Tue Jun 25 07:11:25 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jun 25 07:11:32 2013 Subject: [xsd-users] VS 2012 support In-Reply-To: References: Message-ID: Hi Denis, Denis Toporovsky writes: > Do you guys plan to support Visual Studio 2012? I do not see it listed > on supported > platforms page . Yes, "official" support is coming with the next release. Note also that quite a lot of people are already using XSD 3.3.0 with VS 2012 and works just fine. Boris From Rob.Ursem at cmgl.ca Mon Jun 24 13:39:30 2013 From: Rob.Ursem at cmgl.ca (Rob Ursem) Date: Tue Jun 25 07:19:50 2013 Subject: [xsd-users] Issue using proxy for Open Packaging Conventions core-properties schema In-Reply-To: References: Message-ID: Boris, Thanks for that first link. I had found the /OPT:NOREF but the flag I was missing was the "Use library dependency Inputs: YES". That solved my first problem As for the W3CDTF W3CDTF is a SimpleLiteral type which is a _type. Neither W3CDTF nor SimpleLiteral provide access to the text representation of the element as W3CDTF contains no variables or attributes and SimpleLiteral only contains the (optional) lang attribute. There are accessors on _type for _node() which would get me to _node()->getTextContent() but the issue is that _node() returns a nullptr for my W3CDTF instance. I noticed LiquidXML generated code that contained a text element for W3CDTF so I could get it from that node directly but I don't see an equivalent in the XSD generated code. Perhaps there is an option that allows me to get the raw text for the element so I could provide my own interpretation. It seems counter to the philosophy of the library but is that what you meant with "customize the generated type"? I can see I can modify the generated code but I would rather not since there is the option to re-generate it. I haven't tried deriving off the generated code since generally the rest of the generated code does not instantiate or use the derived code. Rob -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Monday, June 24, 2013 6:14 AM To: Rob Ursem Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] Issue using proxy for Open Packaging Conventions core-properties schema Hi Rob, Rob Ursem writes: > > > > > > > > > > > > [...] > > 1. The initialization of types is somehow skipped by the compiler for types > that have not been referenced before. If I don't include line 5 above, > the "dcterm:W3CDTF type is not registered and my parsing (on line 8) > fails. This seems to be an issue with the compiler (VS2012) rather than > with XSD. Are you by any chance packaging the generated code into a static library (.lib)? If so, then this post explains why it won't work out of the box: http://www.codesynthesis.com/pipermail/odb-users/2013-May/001286.html And this followup explains how to make it work with VS: http://www.codesynthesis.com/pipermail/odb-users/2013-May/001289.html > 2. Once the document is parsed I get a 'created_optional' type (which makes > sense). From there on I can get to a dcterms::W3CDTF type (line 13) but I > have not been able to get the date value out of that element. The W3CDTF type is defined as a union of a whole bunch of other types. XSD maps uinons to strings and you will have to figure out which member it it and extract the data yourself. One way to do it would be to customize the generated type. Boris From boris at codesynthesis.com Tue Jun 25 07:38:28 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jun 25 07:38:35 2013 Subject: [xsd-users] Issue using proxy for Open Packaging Conventions core-properties schema In-Reply-To: References: Message-ID: Hi Rob, Rob Ursem writes: > As for the W3CDTF W3CDTF is a SimpleLiteral type which is a _type. I looked up the definition of SimpleLiteral and it is a restriction of anyType, which in XSD is mapped to xml_schema::type. > Neither W3CDTF nor SimpleLiteral provide access to the text > representation of the element as W3CDTF contains no variables or > attributes and SimpleLiteral only contains the (optional) lang > attribute. Yes, anyType can contain any content (any mixture of text and elements). In fact the definition of SimpleLiteral is quite bizarre in that they take anyType and restrict it to only allowing text content. Why not just use string as a base type then? > There are accessors on _type for _node() which would get me to > _node()->getTextContent() but the issue is that _node() returns > a nullptr for my W3CDTF instance. This will work if you enable DOM association during parsing. See Section 5.1, "DOM Association" in the C++/Tree Mapping User Manual: http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#5.1 > Perhaps there is an option that allows me to get the raw text for the > element so I could provide my own interpretation. Yes, DOM association is that option. > It seems counter to the philosophy of the library but is that what you > meant with "customize the generated type"? I can see I can modify the > generated code but I would rather not since there is the option to > re-generate it. I haven't tried deriving off the generated code since > generally the rest of the generated code does not instantiate or use > the derived code. No, XSD provides proper support for type customization which doesn't require you to modify the generated code. For more information on type customization see the C++/Tree Mapping Customization Guide: http://wiki.codesynthesis.com/Tree/Customization_guide As well as the examples in the examples/cxx/tree/custom/ directory. In particular, the 'mixed' example shows how to do pretty much what you want. Using this approach you could customize the SimpleLiteral type to contain/return the string you are interested in. Or you could customize W3CDTF to contain/return a date-time value. Or both. The advantages of the type customization approach compared to DOM association is that the client code can use clean API (no need to know anything about DOM). Plus, it works for both parsing and serialization (DOM association only works for parsing). Boris From topoden at gmail.com Tue Jun 25 08:20:56 2013 From: topoden at gmail.com (Denis Toporovsky) Date: Tue Jun 25 08:21:25 2013 Subject: [xsd-users] VS 2012 support In-Reply-To: References: Message-ID: Great, thank you. Do you have any kind of 'road map' where I can see a due date for the next release? On Tue, Jun 25, 2013 at 7:11 AM, Boris Kolpackov wrote: > Hi Denis, > > Denis Toporovsky writes: > > > Do you guys plan to support Visual Studio 2012? I do not see it listed > > on supported > > platforms page < > http://www.codesynthesis.com/products/xsd/platforms.xhtml>. > > Yes, "official" support is coming with the next release. Note also that > quite a lot of people are already using XSD 3.3.0 with VS 2012 and works > just fine. > > Boris > > From boris at codesynthesis.com Tue Jun 25 08:42:44 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jun 25 08:42:51 2013 Subject: [xsd-users] VS 2012 support In-Reply-To: References: Message-ID: Hi Denis, Denis Toporovsky writes: > Do you have any kind of 'road map' where I can see a due date for the > next release? The next release is planned for end-Aug/beg-Sep. Boris From om_codesynthesis at keywallet.com Tue Jun 25 10:35:50 2013 From: om_codesynthesis at keywallet.com (Ovanes Markarian) Date: Tue Jun 25 10:36:20 2013 Subject: [xsd-users] compiling on Linux fails with name-lookup errors Message-ID: Hi *, just trying to compile my code on Linux with gcc 4.8.1. Installed XSD 3.3.0 using the apt-get and I get tons of ADL errors. In file included from /usr/include/xsd/cxx/parser/validating/parser.hxx:469:0, from /home/.../code/xml/files.index-pskel.hxx:75, from /home/.../xml/files.index-pskel.cxx:39: /usr/include/xsd/cxx/parser/validating/parser.txx: In instantiation of 'void xsd::cxx::parser::validating::simple_content::_characters(const xsd::cxx::ro_string&) [with C = char]': /home/.../xml/files.index-pskel.cxx:1854:46: required from here /usr/include/xsd/cxx/parser/validating/parser.txx:229:37: error: '_characters_impl' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] if (!_characters_impl (str)) ^ /usr/include/xsd/cxx/parser/validating/parser.txx:229:37: note: declarations in dependent base 'xsd::cxx::parser::validating::empty_content' are not found by unqualified lookup /usr/include/xsd/cxx/parser/validating/parser.txx:229:37: note: use 'this->_characters_impl' instead /usr/include/xsd/cxx/parser/validating/parser.txx:248:44: error: '_unexpected_characters' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] _unexpected_characters (str); ^ /usr/include/xsd/cxx/parser/validating/parser.txx:248:44: note: declarations in dependent base 'xsd::cxx::parser::validating::empty_content' are not found by unqualified lookup /usr/include/xsd/cxx/parser/validating/parser.txx:248:44: note: use 'this->_unexpected_characters' instead /usr/include/xsd/cxx/parser/validating/parser.txx: In instantiation of 'void xsd::cxx::parser::validating::complex_content::_start_element(const xsd::cxx::ro_string&, const xsd::cxx::ro_string&, const xsd::cxx::ro_string*) [with C = char]': /home/.../xml/files.index-pskel.cxx:2452:1: required from here /usr/include/xsd/cxx/parser/validating/parser.txx:325:49: error: '_start_any_element' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] _start_any_element (ns, name, type); ^ /usr/include/xsd/cxx/parser/validating/parser.txx:325:49: note: declarations in dependent base 'xsd::cxx::parser::validating::empty_content' are not found by unqualified lookup I saw that post: http://codesynthesis.com/pipermail/xsd-users/2012-August/003737.html But my question is, if I can smth to avoid upgrading to this version? The major blocking issue is that I don't like the idea of regenerating skeletons etc, as I get the version mismatch error when just updating to the new version. Many thanks, Ovanes From Rob.Ursem at cmgl.ca Tue Jun 25 15:48:19 2013 From: Rob.Ursem at cmgl.ca (Rob Ursem) Date: Wed Jun 26 07:44:09 2013 Subject: [xsd-users] Issue using proxy for Open Packaging Conventions core-properties schema In-Reply-To: References: Message-ID: Boris, I've been able to successfully customize the SimpleLiteral type and get the text element from that. Thanks to the clear write up and examples! It didn't help me very much though since with the next element I got stuck again. The opc-coreProperties schema uses the following definition for CoreProperties: In dc.xsd the following is defined ... ... XSD maps title, creator, description and identifier onto // identifier // typedef ::xml_schema::type identifier_type; Thus far I have not been able to customize xml_schema::type. I thought that since there is a definition of the "any" element (of type SimpleLiteral) that any element in the "any" substitution group would be of the SimpleLiteral type. This would make my customization work like a charm. Instead it seems that XSD is interpreting substitutionGroup="any" as the "xs:any" type. My short term work around (I've spent several days on what should be trivial) is to replace substitutionGroup="any" by type="SimplLiteral" in dc.xsd. This makes all the code working and now my tests pass. But it still doesn't feel right. Is there anything else I have missed (or another manual page / example I should have looked at?) :-) Thanks for all your help. This is only the first step of my evaluation as about 220 XML objects await my interpretation next. Regards, Rob -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Tuesday, June 25, 2013 5:38 AM To: Rob Ursem Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] Issue using proxy for Open Packaging Conventions core-properties schema Hi Rob, Rob Ursem writes: > As for the W3CDTF W3CDTF is a SimpleLiteral type which is a _type. I looked up the definition of SimpleLiteral and it is a restriction of anyType, which in XSD is mapped to xml_schema::type. > Neither W3CDTF nor SimpleLiteral provide access to the text > representation of the element as W3CDTF contains no variables or > attributes and SimpleLiteral only contains the (optional) lang > attribute. Yes, anyType can contain any content (any mixture of text and elements). In fact the definition of SimpleLiteral is quite bizarre in that they take anyType and restrict it to only allowing text content. Why not just use string as a base type then? > There are accessors on _type for _node() which would get me to > _node()->getTextContent() but the issue is that _node() returns a > nullptr for my W3CDTF instance. This will work if you enable DOM association during parsing. See Section 5.1, "DOM Association" in the C++/Tree Mapping User Manual: http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#5.1 > Perhaps there is an option that allows me to get the raw text for the > element so I could provide my own interpretation. Yes, DOM association is that option. > It seems counter to the philosophy of the library but is that what you > meant with "customize the generated type"? I can see I can modify the > generated code but I would rather not since there is the option to > re-generate it. I haven't tried deriving off the generated code since > generally the rest of the generated code does not instantiate or use > the derived code. No, XSD provides proper support for type customization which doesn't require you to modify the generated code. For more information on type customization see the C++/Tree Mapping Customization Guide: http://wiki.codesynthesis.com/Tree/Customization_guide As well as the examples in the examples/cxx/tree/custom/ directory. In particular, the 'mixed' example shows how to do pretty much what you want. Using this approach you could customize the SimpleLiteral type to contain/return the string you are interested in. Or you could customize W3CDTF to contain/return a date-time value. Or both. The advantages of the type customization approach compared to DOM association is that the client code can use clean API (no need to know anything about DOM). Plus, it works for both parsing and serialization (DOM association only works for parsing). Boris From Andreas.Hackeloeer at bmw.de Wed Jun 26 07:07:46 2013 From: Andreas.Hackeloeer at bmw.de (Andreas.Hackeloeer@bmw.de) Date: Wed Jun 26 07:44:10 2013 Subject: [xsd-users] Assignment of optional boolean attribute does not survive on the heap; possibly a bug? Message-ID: <7F5DDDF6FC26724C93C8DAFA6DBFCDFD0149B36EAE@SMUCM04V.europe.bmw.corp> Hi, I am encountering the following problem: I have this schema: An XML file according to this schema might look like this: I have no problems loading this XML file. I can enumerate and modify the Map element using this code: std::tr1::shared_ptr myConfig = configuration("test.xml"); MapManagerType& myMapManager = myConfig->mapManager(); MapManagerType::MapSequence& myMapSequence = myMapManager.map(); for (MapManagerType::MapIterator i (myMapSequence.begin()); i != myMapSequence.end(); i++) { MapType& myMap(*i); myMap.title("New Title"); // works, Title attribute keeps its new value myMap.selectedSourceMap(true); // does not work bool problem = myMap.selectedSourceMap(); // true only as long as the method is being executed } The strange thing: Assigning a new string to the Title attribute works, however, assigning a boolean value to the optional boolean attribute SelectedSourceMap does not work. More precisely: The SelectedSourceMap attribute gets assigned the new value, however, after the scope of the method is left, the attribute is reset to false, while the Title attribute keeps its new value. I am accessing the model using a shared_ptr class member variable. Does anyone have a clue what might be causing the problem? I would greatly appreciate any help! Best regards, Andreas Hackeloeer From boris at codesynthesis.com Wed Jun 26 07:51:59 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jun 26 07:52:07 2013 Subject: [xsd-users] compiling on Linux fails with name-lookup errors In-Reply-To: References: Message-ID: Hi Ovanes, Ovanes Markarian writes: > just trying to compile my code on Linux with gcc 4.8.1. Installed XSD 3.3.0 > using the apt-get and I get tons of ADL errors. This is a known issue that has been fixed for the upcoming release. > But my question is, if I can smth to avoid upgrading to this version? The > major blocking issue is that I don't like the idea of regenerating > skeletons etc, as I get the version mismatch error when just updating to > the new version. There is a patch available for XSD 3.3.0: http://www.codesynthesis.com/~boris/tmp/xsd/xsd-3.3.0-gcc-4.7-clang.patch Boris From erik.sjolund at gmail.com Wed Jun 26 08:03:23 2013 From: erik.sjolund at gmail.com (=?ISO-8859-1?Q?Erik_Sj=F6lund?=) Date: Wed Jun 26 08:03:30 2013 Subject: [xsd-users] Assignment of optional boolean attribute does not survive on the heap; possibly a bug? In-Reply-To: <7F5DDDF6FC26724C93C8DAFA6DBFCDFD0149B36EAE@SMUCM04V.europe.bmw.corp> References: <7F5DDDF6FC26724C93C8DAFA6DBFCDFD0149B36EAE@SMUCM04V.europe.bmw.corp> Message-ID: On Wed, Jun 26, 2013 at 1:07 PM, wrote: > > > > use="optional" /> > > > > > { > MapType& myMap(*i); > myMap.title("New Title"); // works, Title attribute keeps its new > value > myMap.selectedSourceMap(true); // does not work > bool problem = myMap.selectedSourceMap(); // true only as long as the > method is being executed > } > > You could try something like: myMap.selectedSourceMap().set(true); if (myMap.selectedSourceMap().present()) { bool problem = myMap.selectedSourceMap().get(); } cheers, Erik Sj?lund From boris at codesynthesis.com Wed Jun 26 08:07:05 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jun 26 08:07:13 2013 Subject: [xsd-users] Assignment of optional boolean attribute does not survive on the heap; possibly a bug? In-Reply-To: <7F5DDDF6FC26724C93C8DAFA6DBFCDFD0149B36EAE@SMUCM04V.europe.bmw.corp> References: <7F5DDDF6FC26724C93C8DAFA6DBFCDFD0149B36EAE@SMUCM04V.europe.bmw.corp> Message-ID: Hi Andreas, Andreas.Hackeloeer@bmw.de writes: > > > [...] > > myMap.selectedSourceMap(true); > bool problem = myMap.selectedSourceMap(); Because SelectedSourceMap is optional, what you get from selectedSourceMap() is not the value, but the optional container (see the part of the documentation that discusses cardinalities). So the above code should be something along these lines: if (myMap.selectedSourceMap().preset ()) { // Attribute is present, get its value. // bool val = myMap.selectedSourceMap().get (); } Or, using the pointer notation: if (myMap.selectedSourceMap()) { // Attribute is present, get its value. // bool val = *myMap.selectedSourceMap(); } Boris From boris at codesynthesis.com Wed Jun 26 08:29:37 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jun 26 08:29:45 2013 Subject: [xsd-users] Issue using proxy for Open Packaging Conventions core-properties schema In-Reply-To: References: Message-ID: Hi Rob, Rob Ursem writes: > > > > > > > > I thought that since there is a definition of the "any" element (of type > SimpleLiteral) that any element in the "any" substitution group would be of > the SimpleLiteral type. This would make my customization work like a > charm. Instead it seems that XSD is interpreting substitutionGroup="any" as > the "xs:any" type. Normally, when you don't specify a type for an element, XML Schema spec defaults to anyType. But apparently if an element is a member of a substitution group, then instead it "inherits" the type of the group's root. XSD doesn't handle this special case, which is a bug. I am going to go ahead and fix it for the next release. Also, if you would like, I can build you a pre-release binary with the fix. Just let me know which platform you are using. > Thus far I have not been able to customize xml_schema::type. It is possible to do that. This earlier post has more information: http://www.codesynthesis.com/pipermail/xsd-users/2009-October/002492.html > My short term work around (I've spent several days on what should be trivial) > is to replace substitutionGroup="any" by type="SimplLiteral" in dc.xsd. > This makes all the code working and now my tests pass. But it still doesn't > feel right. No, there is actually nothing wrong with this since your schema is semantically equivalent to the original. You just explicitly specified the type which should have been used implicitly. Boris From Andreas.Hackeloeer at bmw.de Wed Jun 26 08:26:42 2013 From: Andreas.Hackeloeer at bmw.de (Andreas.Hackeloeer@bmw.de) Date: Wed Jun 26 08:30:13 2013 Subject: [xsd-users] Assignment of optional boolean attribute does not survive on the heap; possibly a bug? In-Reply-To: References: <7F5DDDF6FC26724C93C8DAFA6DBFCDFD0149B36EAE@SMUCM04V.europe.bmw.corp> Message-ID: <7F5DDDF6FC26724C93C8DAFA6DBFCDFD0149B36F34@SMUCM04V.europe.bmw.corp> Hi Boris and Erik, thank you very much for your help! I now tried the following: Method A: myMap.selectedSourceMap().set(true); Method B later called by method A: if (myMap.selectedSourceMap().present() && myMap.selectedSourceMap().get()) { // This is never reached } Unfortunately, it still does not work. It looks like the Present flag is set to false as soon as the scope of the method is left. The debugger tells me that immediately after the set() method is called, the following holds: myMap.SelectedSourceMap_.present_ == true myMap.SelectedSourceMap_.x_ == true After this method has called a new method which uses the shared_ptr class member reference to the xml mapping and re-iterates the map element, the following holds: myMap.SelectedSourceMap_.present_ == false myMap.SelectedSourceMap_.x_ == true It looks like the boolean value is "forgotten" after leaving the stack while the string value (Title attribute) survives. Regards, Andreas From boris at codesynthesis.com Wed Jun 26 08:36:33 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jun 26 08:36:41 2013 Subject: [xsd-users] Assignment of optional boolean attribute does not survive on the heap; possibly a bug? In-Reply-To: <7F5DDDF6FC26724C93C8DAFA6DBFCDFD0149B36F34@SMUCM04V.europe.bmw.corp> References: <7F5DDDF6FC26724C93C8DAFA6DBFCDFD0149B36EAE@SMUCM04V.europe.bmw.corp> <7F5DDDF6FC26724C93C8DAFA6DBFCDFD0149B36F34@SMUCM04V.europe.bmw.corp> Message-ID: Hi Andreas, Andreas.Hackeloeer@bmw.de writes: > It looks like the boolean value is "forgotten" after leaving the stack > while the string value (Title attribute) survives. Hm, this is strange. I would say a copy is made somewhere but the fact that the string value is updated successfully indicates that this is not the problem. Can you create a small test case (schema and C++ source file) that reproduce this problem and send it to me? I will then try to figure out what's going on. Boris From erik.sjolund at gmail.com Wed Jun 26 08:40:12 2013 From: erik.sjolund at gmail.com (=?ISO-8859-1?Q?Erik_Sj=F6lund?=) Date: Wed Jun 26 08:40:20 2013 Subject: [xsd-users] Assignment of optional boolean attribute does not survive on the heap; possibly a bug? In-Reply-To: References: <7F5DDDF6FC26724C93C8DAFA6DBFCDFD0149B36EAE@SMUCM04V.europe.bmw.corp> <7F5DDDF6FC26724C93C8DAFA6DBFCDFD0149B36F34@SMUCM04V.europe.bmw.corp> Message-ID: Maybe this line MapManagerType& myMapManager = myConfig->mapManager(); should be MapManagerType& myMapManager (myConfig->mapManager()); cheers, Erik Sj?lund From Andreas.Hackeloeer at bmw.de Wed Jun 26 09:06:54 2013 From: Andreas.Hackeloeer at bmw.de (Andreas.Hackeloeer@bmw.de) Date: Wed Jun 26 09:07:56 2013 Subject: [xsd-users] Assignment of optional boolean attribute does not survive on the heap; possibly a bug? In-Reply-To: References: <7F5DDDF6FC26724C93C8DAFA6DBFCDFD0149B36EAE@SMUCM04V.europe.bmw.corp> <7F5DDDF6FC26724C93C8DAFA6DBFCDFD0149B36F34@SMUCM04V.europe.bmw.corp> Message-ID: <7F5DDDF6FC26724C93C8DAFA6DBFCDFD0149B36F6E@SMUCM04V.europe.bmw.corp> Hi Boris and Erik, I finally found the solution. Sorry for bothering you - the reason didn't have anything to do with CodeSynthesis XSD, as it turned out. I have a Qt UI which fills a combo box with the Map elements found in the XML. In the second method which is called by the first one, I call a clear() on the combo box beforehand. However, I registered an event handler on the currentIndexChanged() event ("signal" in Qt terminology) which gets fired when the user changes the current item, but appearently also when you do a clear() programmatically, which I was not aware of. Within this event handler, I changed the selectedSourceMap attribute of the XML representation to match with the currently selected item (but not the Title attribute, which is why this remained the same). The obvious solution is to disable the event handler before calling clear(). Then, the selectedSourceMap attribute behaves as it is supposed to. I did not quote the Qt stuff because I thought it was irrelevant to the problem. Sorry for that. And thanks a lot for time and your advice! Best regards, Andreas From Al.Niessner at gmx.net Mon Jun 24 21:18:52 2013 From: Al.Niessner at gmx.net (Al Niessner) Date: Wed Jun 26 09:28:31 2013 Subject: [xsd-users] controlling the pretty printer format Message-ID: <1372123132.2567.5.camel@charon> I am using XSD to serialize an XML object-tree in memory. While a machine is processing the XML so are humans. The standard serialization looks good, but I want to be nit-picky and control more of it. I would like three spaces for indentation instead of two. I like my attributes on separate lines, etc. What is the easiest way to control the pretty printer format of serialization? I am a bit of a newbie to XSD but have used jaxb and pyxb for a while now. I did the obligatory google searches and searches on this email list. Either I am not guessing what the magic words to search or there just are no hits (I am guessing the former). Any and all help is appreciated. -- Al Niessner I have never found the companion that was so companionable as solitude. - From Walden by Henry David Thoreau The universe is indifferent, and life is brutal; however, it is man's choice of behavior that makes them malevolent rather than benevolent. Some will fall in love with life and drink it from a fountain That is pouring like an avalanche coming down the mountain. - From the song Pepper by the Butthole Surfers From boris at codesynthesis.com Wed Jun 26 09:42:59 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jun 26 09:43:06 2013 Subject: [xsd-users] controlling the pretty printer format In-Reply-To: <1372123132.2567.5.camel@charon> References: <1372123132.2567.5.camel@charon> Message-ID: Hi Al, Al Niessner writes: > > I am using XSD to serialize an XML object-tree in memory. While a > machine is processing the XML so are humans. The standard serialization > looks good, but I want to be nit-picky and control more of it. I would > like three spaces for indentation instead of two. I like my attributes > on separate lines, etc. What is the easiest way to control the pretty > printer format of serialization? Write your own XML serializer? Seriously, though, XSD uses Xerces-C++ DOM serializer and as far as I know it doesn't allow this kind of deep customizations. Maybe you can derive your own serializer from it and customize those things, but I don't know for sure. Boris From Wesley.Peters at tachyon.com Wed Jun 26 15:25:16 2013 From: Wesley.Peters at tachyon.com (Wesley Peters) Date: Thu Jun 27 06:28:27 2013 Subject: [xsd-users] controlling the pretty printer format In-Reply-To: Message-ID: Just take the XML the human beings are going to read and toss it into XML::LibXML::PrettyPrint. This is the sort of thing Perl was made for. On 6/26/13 6:42 AM, "Boris Kolpackov" wrote: Hi Al, Al Niessner writes: > > I am using XSD to serialize an XML object-tree in memory. While a > machine is processing the XML so are humans. The standard serialization > looks good, but I want to be nit-picky and control more of it. I would > like three spaces for indentation instead of two. I like my attributes > on separate lines, etc. What is the easiest way to control the pretty > printer format of serialization? Write your own XML serializer? Seriously, though, XSD uses Xerces-C++ DOM serializer and as far as I know it doesn't allow this kind of deep customizations. Maybe you can derive your own serializer from it and customize those things, but I don't know for sure. Boris ________________________________ Confidentiality Notice: The information contained in this electronic e-mail and any accompanying attachment(s) is intended only for the use of the intended recipient and is confidential and/or privileged. If you and we have a confidentiality agreement or other non-disclosure obligations between us, this Notice shall be deemed to mark and identify the content of this email and any attachments as confidential and proprietary. If any reader of this communication is not the intended recipient, unauthorized use, disclosure or copying is strictly prohibited, and may be unlawful. If you have received this communication in error, please immediately notify the sender by return e-mail, and delete the original message and all copies from your system. Thank you. IRS Circular 230 Disclosure: To ensure compliance with requirements imposed by the IRS, please be advised that any U.S. federal tax advice contained in this communication (including any attachments) is not intended or written to be used or relied upon, and cannot be used or relied upon, for the purpose of (i) avoiding penalties under the Internal Revenue Code, or (ii) promoting, marketing or recommending to another party any transaction or matter addressed herein. E-mail is susceptible to data corruption, interception, unauthorized amendment, tampering and viruses, and we only send and receive e-mails on the basis that we are not liable for any such corruption, interception, amendment, tampering or viruses or any consequences thereof. From om_codesynthesis at keywallet.com Thu Jun 27 07:36:53 2013 From: om_codesynthesis at keywallet.com (Ovanes Markarian) Date: Thu Jun 27 07:37:23 2013 Subject: [xsd-users] compiling on Linux fails with name-lookup errors In-Reply-To: References: Message-ID: Thanks worked like a charm. On Wed, Jun 26, 2013 at 1:51 PM, Boris Kolpackov wrote: > Hi Ovanes, > > Ovanes Markarian writes: > > > just trying to compile my code on Linux with gcc 4.8.1. Installed XSD > 3.3.0 > > using the apt-get and I get tons of ADL errors. > > This is a known issue that has been fixed for the upcoming release. > > > > But my question is, if I can smth to avoid upgrading to this version? The > > major blocking issue is that I don't like the idea of regenerating > > skeletons etc, as I get the version mismatch error when just updating to > > the new version. > > There is a patch available for XSD 3.3.0: > > http://www.codesynthesis.com/~boris/tmp/xsd/xsd-3.3.0-gcc-4.7-clang.patch > > Boris > > From om_codesynthesis at keywallet.com Thu Jun 27 07:56:31 2013 From: om_codesynthesis at keywallet.com (Ovanes Markarian) Date: Thu Jun 27 07:57:00 2013 Subject: [xsd-users] C++ 11 move semantics Message-ID: Now I run into the issue where I use a unique point from the C++ 11 standard with xsd 3.3.0 and that obviously fails :( since internally an l-value is generated from r-value. Here an example: One of my parsers returns: std::unique_ptr The base parser skeleton has the following construct: std::unique_ptr tmp (this->Underlying_parser_->post_WhatEverType()); this->WhatEverType (tmp); Here I need to either use an explicit move: std::move(tmp) or pass the r-value to the WhatEverType function: std::unique_ptr tmp (this->Underlying_parser_->post_WhatEverType()); this->WhatEverType (std::move(tmp)); or this->WhatEverType(this->Underlying_parser_->post_WhatEverType()) Is there any work around for that? Can I specify in a type-map file a move function to be used. Or do I really need to write a wrapper type, which will accept the unique_ptr and move it implicitly for me? Many thanks, Ovanes P.S: I would not like to deal with deprecated auto_ptr. From om at keywallet.com Thu Jun 27 07:55:12 2013 From: om at keywallet.com (Ovanes Markarian) Date: Thu Jun 27 07:59:08 2013 Subject: [xsd-users] C++11 move semantics Message-ID: Now I run into the issue where I use a unique point from the C++ 11 standard with xsd 3.3.0 and that obviously fails :( since internally an l-value is generated from r-value. Here an example: One of my parsers returns: std::unique_ptr The base parser skeleton has the following construct: std::unique_ptr tmp (this->Underlying_parser_->post_WhatEverType()); this->WhatEverType (tmp); Here I need to either use an explicit move: std::move(tmp) or pass the r-value to the WhatEverType function: std::unique_ptr tmp (this->Underlying_parser_->post_WhatEverType()); this->WhatEverType (std::move(tmp)); or this->WhatEverType(this->Underlying_parser_->post_WhatEverType()) Is there any work around for that? Can I specify in a type-map file a move function to be used. Or do I really need to write a wrapper type, which will accept the unique_ptr and move it implicitly for me? Many thanks, Ovanes P.S: I would not like to deal with deprecated auto_ptr. From boris at codesynthesis.com Thu Jun 27 08:06:38 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jun 27 08:06:46 2013 Subject: [xsd-users] C++ 11 move semantics In-Reply-To: References: Message-ID: Hi Ovanes, Please don't post multiple copies of the same. If you sent it from an unsubscribed address, just wait for it to go through moderation. Ovanes Markarian writes: > The base parser skeleton has the following construct: > > std::unique_ptr tmp > (this->Underlying_parser_->post_WhatEverType()); > this->WhatEverType (tmp); > > Here I need to either use an explicit move: std::move(tmp) or pass the > r-value to the WhatEverType function: > > std::unique_ptr tmp > (this->Underlying_parser_->post_WhatEverType()); > this->WhatEverType (std::move(tmp)); > > or > > this->WhatEverType(this->Underlying_parser_->post_WhatEverType()) > > > Is there any work around for that? A few that I see: 1. Accept the pointer in WhatEverType() as an l-value reference. Inside you can call std::move() yourself. 2. Use shared_ptr. > Can I specify in a type-map file a move function to be used. No, this is not currently supported. Boris From om_codesynthesis at keywallet.com Thu Jun 27 08:25:01 2013 From: om_codesynthesis at keywallet.com (Ovanes Markarian) Date: Thu Jun 27 08:25:30 2013 Subject: [xsd-users] C++ 11 move semantics In-Reply-To: References: Message-ID: On Thu, Jun 27, 2013 at 2:06 PM, Boris Kolpackov wrote: > Hi Ovanes, > > Please don't post multiple copies of the same. If you sent it from an > unsubscribed address, just wait for it to go through moderation. > Oh, sorry. Did not know, how the mailing list is configured, some just automatically refuse such emails. > > > Ovanes Markarian writes: > > > The base parser skeleton has the following construct: > > > > std::unique_ptr tmp > > (this->Underlying_parser_->post_WhatEverType()); > > this->WhatEverType (tmp); > > > > Here I need to either use an explicit move: std::move(tmp) or pass the > > r-value to the WhatEverType function: > > > > std::unique_ptr tmp > > (this->Underlying_parser_->post_WhatEverType()); > > this->WhatEverType (std::move(tmp)); > > > > or > > > > this->WhatEverType(this->Underlying_parser_->post_WhatEverType()) > > > > > > Is there any work around for that? > > A few that I see: > > 1. Accept the pointer in WhatEverType() as an l-value reference. Inside > you can call std::move() yourself. > > 2. Use shared_ptr. > > > > Can I specify in a type-map file a move function to be used. > > No, this is not currently supported. > > Boris > Ok, I just did some dirty hack and modified the generated code. Otherwise, it is not descriptive that the ownership is transferred and I also don't want to have some shared state, as some people, who are going to maintain my code might come to the idea to store such a pointer... IMO, hacking the generated code is the best alternative, as it breaks the newly generated code and forces the developer to understand the impact, instead of accepting smth silently and transferring the ownership it in an non-obvious way. Do you plan to solve that issue in an upcoming release? Are there any plans for the upcoming release? Thanks for your help, Ovanes