aboutsummaryrefslogtreecommitdiff
path: root/xsd-frontend
diff options
context:
space:
mode:
Diffstat (limited to 'xsd-frontend')
-rw-r--r--xsd-frontend/parser.cxx20
1 files changed, 17 insertions, 3 deletions
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<SemanticGraph::Element> (ns_name, uq_name, s_, cache_));
s_.new_edge<Substitutes> (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<Belongs> (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<Belongs> (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 () << ": "