From d79dc02eab2a560dc075ebbbe3bf14f62082ab5f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 4 Jul 2013 09:15:26 +0200 Subject: Handle case of unspecified element type in substitution group --- xsd-frontend/parser.cxx | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'xsd-frontend') diff --git a/xsd-frontend/parser.cxx b/xsd-frontend/parser.cxx index dbe070c..65fb703 100644 --- a/xsd-frontend/parser.cxx +++ b/xsd-frontend/parser.cxx @@ -415,6 +415,15 @@ namespace XSDFrontend resolve (ns_name, uq_name, s_, cache_)); s_.new_edge (e, root); + + // See if we need to derive the type of this element from the + // one it substitutes. + // + if (!e.typed_p ()) + { + resolve_member (root); // Make sure the type is resolved. + s_.new_edge (e, root.type ()); + } } catch (NotNamespace const& ex) { @@ -3825,6 +3834,7 @@ namespace XSDFrontend default_values_.push_back (&node); } + bool subst (false); if (global) { if (String sg = trim (e["substitutionGroup"])) @@ -3832,6 +3842,8 @@ namespace XSDFrontend if (trace_) wcout << "substitutes " << sg << endl; + subst = true; + try { String uq_name (unqualified_name (sg)); @@ -3900,10 +3912,12 @@ namespace XSDFrontend if (t) s_->new_edge (node, *t); } - else + // By default the type is anyType unless this element is a + // member of a substitution group, in which case it has the + // same type as the element it substiutes. + // + else if (!subst) { - // anyType - // if (!is_disabled ("F001")) { wcerr << file () << ":" << e.line () << ":" << e.column () << ": " -- cgit v1.1