From n.weidmann at lombardodier.com Fri Jul 3 04:30:57 2026 From: n.weidmann at lombardodier.com (Nicolas Weidmann) Date: Fri Jul 3 09:00:25 2026 Subject: [Ext] Re: [xsd-users] DLLs and --generate-element-type --generate-element-map In-Reply-To: References: <137e71d8d36949ef8972a46f2cb212ac@lombardodier.com> <4a98add6123e4b6b9df979fbe42efe2c@lombardodier.com> Message-ID: Hello Boris, I could give it a try yesterday and this morning. Using both --export-xml-schema & --export-symbol worked as you expected. However, with MSVC, I encountered the same issue I had with xsd::cxx::tree::string regarding std::string being multiple-defined. I then dropped --export-xml-schema & --export-symbol and added to my xml_schema epilogue: template class XML_SCHEMA_EXPORT ::xsd::cxx::tree::element_map; With this it works. I however had to add the following operators to my code as I am using a custom double: void operator<<(xercesc::DOMElement& e, double d) void operator<<(xercesc::DOMAttr& a, double d) void operator<<(xml_schema::ListStream& ls, double d) // For in house conventions, I use --type-naming ucc --function-naming java Are there other templates I MUST export other than ::xsd::cxx::tree::element_map<...> to have full type support with my base lib? I noticed --export-maps, but didn't see any differences in the xml_schema header file generated. But the documentation mentions: Export polymorphism support maps... So, I should probably export other maps as well!?! Another question, when using --generate-element-type --generate-element-map, I have to use element_map<...>::parse & serialize Are there equivalent helpers to ::std::unique_ptr< :: my_namespace::MyElement > parseMyElement (::std::istream& is, ::xml_schema::Flags f = 0, const ::xml_schema::Properties& p = ::xml_schema::Properties ()); void serializeMyElement (::std::ostream& os, const ::my_namespace::MyElement& x, const ::xml_schema::NamespaceInfomap& m = ::xml_schema::NamespaceInfomap (), const ::std::string& e = "UTF-8", ::xml_schema::Flags f = 0); For the moment I wrote template helper functions that do the work, but if something already exists, it would be much better for me to use it instead of my own helpers: template std::unique_ptr parse(std::istream& stream, xml_schema::Flags flags = 0, const xml_schema::Properties& properties = {}) void serialize(std::ostream& stream, const xml_schema::ElementType& element, const xml_schema::NamespaceInfomap& infomap = {}, const char* encoding = nullptr, xml_schema::Flags flags = 0); Regards, Nicolas Weidmann Banque Lombard Odier & Cie SA Rue de la Corraterie 11 - 1204 Gen?ve - Suisse T +41 22 709 23 17 www.lombardodier.com -----Original Message----- From: Boris Kolpackov Sent: mardi, 30 juin 2026 16:11 To: Nicolas Weidmann Cc: xsd-users@codesynthesis.com Subject: [Ext] Re: [xsd-users] DLLs and --generate-element-type --generate-element-map Nicolas Weidmann writes: > I wanted to use --generate-element-type --generate-element-map in > order to have a single parse & serialize as our code heavily relies > on templates and parseMyType, etc. are not generic. > > It works fine as long as all the libs are static, but I need to have > the different data-binding libraries to be DLLs. > > In that case, it fails as the different dlls have their own element > map and the application code has its own, empty, element map. > > Do I have to implement my own --custom-type for the element map? No, the overall approach is to have a "root" DLL that exports the single map that everyone else imports. The element map is a class template (with a static data member which is the actual map) and exporting templates from DLLs is a murky business. If you want to give it a go, the starting point would be to generate the header for XML Schema built-in types (which includes the element_map) and export it from your root DLL. Something along these lines: xsd cxx-tree \ --generate-element-map \ --generate-element-type \ --export-xml-schema \ --export-symbol XML_SCHEMA_EXPORT \ --generate-xml-schema \ xml-schema.xsd You would need to define XML_SCHEMA_EXPORT appropriately. You will also need to have this header included in at least one source file that belongs to the root DLL in order to have the template instantiations exported. Once this is done, all your actual schemas would be compiled with --extern-xml-schema in order to use this shared header. [[ rethink everything. ]] [[LinkedIn]] [[Twitter]] [[Facebook]] [[Instagram]] [[YouTube]] *** IMPORTANT NOTICE REGARDING INSTRUCTIONS by EMAIL *** Please be aware that instructions received by e-mail should be considered delayed and not executed unless they have been specifically confirmed by your relationship manager/banker. Email traffic during turbulent times in the financial markets is high and cannot always be acted upon at all times. Lombard Odier cannot be held liable for such delay in execution or for the non-execution of an instruction given by email even if it was given in due time. Therefore, instructions requiring immediate action must be communicated by telephone by calling the bank?s registered landline. Thank you for your understanding. *** IMPORTANT INFORMATION ABOUT DATA PROTECTION *** You might be receiving this because you have provided us with your contact details. If this is the case note that we may process your personal data for direct marketing purposes. If you wish to object to this processing, please notify the Group?s Data Protection Officer. For more information: www.lombardodier.com/privacy-policy DISCLAIMER ********************************************** This message is intended only for use by the person to whom it is addressed. It may contain information that is privileged and confidential. Its content does not constitute a formal commitment by any company of the Lombard Odier group. If you are not the intended recipient of this message, kindly notify the sender immediately and destroy this message. Thank You. *******************************************************(dch)*