[Ext] Re: [xsd-users] DLLs and --generate-element-type --generate-element-map

Boris Kolpackov boris at codesynthesis.com
Tue Jul 7 03:30:18 EDT 2026


Nicolas Weidmann <n.weidmann at lombardodier.com> writes:

> 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<C, B> regarding std::string being multiple-defined.

Did you arrange for a custom XML Schema string type when compiling
with --generate-xml-schema? I suspect with --export-xml-schema you
may have to similarly customize a few more built-in types that don't
derive from XML Schema string because they are now explicitly exported
(or comment out their export in the generated header).


> 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<char, ::xml_schema::Type>;
> 
> With this it works. I however had to add [...]
> 
> Are there other templates I MUST export [...]?

I wouldn't go this manual export route for exactly this reason: now you
don't know what needs to be exported. If anything, I would go the other
way and comment out exports that cause issues and that you don't need.


> 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!?!

If you use polymorphism and your polymorphic type hierarchies are split
across several DLLs, then yes. Though this works a bit differently since
there is no built-in declarations for such maps, they are implementation
details. I think the documentation for these options (--export-maps and
--import-maps) is pretty clear on what needs to be done:

https://codesynthesis.com/projects/xsd/documentation/xsd.xhtml


> Another question, when using --generate-element-type --generate-element-map,
> I have to use element_map<...>::parse & serialize
> 
> Are there equivalent helpers to [...]

No, the element types/maps are a pretty low-level (but flexible) mechanism
that you would normally wrap in a more restricted interface suitable for your
application.



More information about the xsd-users mailing list