From 2a700917616a2cc0e751adb76d8f71348a80b0d8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 10 Dec 2021 11:24:56 +0200 Subject: Enter abstract elements into substitution map We cannot just omit them because they may serve as "links" between the root of the substitution group and non-abstract elements that use these elements as their roots. --- xsd/xsd/cxx/tree/tree-source.cxx | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'xsd') diff --git a/xsd/xsd/cxx/tree/tree-source.cxx b/xsd/xsd/cxx/tree/tree-source.cxx index 00e895b..d702509 100644 --- a/xsd/xsd/cxx/tree/tree-source.cxx +++ b/xsd/xsd/cxx/tree/tree-source.cxx @@ -3727,24 +3727,36 @@ namespace CXX } } - if (!abst && polymorphic && e.substitutes_p () && - !options.suppress_parsing ()) + // Note that we cannot just omit this element if it's abstract + // because it may serve as a "link" between the root of the + // substitution group and a non-abstract element that uses this + // element as its root (see element_factory_map::find_substitution() + // for details). + // + if (polymorphic && e.substitutes_p () && !options.suppress_parsing ()) { String const& name (ename (e)); Type& r (e.substitutes ().root ()); os << "static" << endl << "const ::xsd::cxx::tree::element_factory_initializer< " << - poly_plate << ", " << char_type << ", "; - - belongs (e, belongs_); - - os << " >" << endl + poly_plate << ", " << char_type << " >" << endl << "_xsd_" << name << "_element_factory_init (" << endl << strlit (r.name ()) << "," << endl << strlit (r.namespace_ ().name ()) << "," << endl << strlit (e.name ()) << "," << endl - << strlit (e.namespace_ ().name ()) << ");" + << strlit (e.namespace_ ().name ()) << "," << endl; + + if (abst) + os << "0"; + else + { + os << "&::xsd::cxx::tree::factory_impl< "; + belongs (e, belongs_); + os << " >"; + } + + os << ");" << endl << endl; } -- cgit v1.1