aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-07-04 09:15:26 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-07-04 09:15:26 +0200
commitd79dc02eab2a560dc075ebbbe3bf14f62082ab5f (patch)
tree470f85f338b6b4c889f0bbb02eeae74f1ee0d37c
parent93dfe8d00dc4ea19b31ebcf4dab35a32cd1d6791 (diff)
Handle case of unspecified element type in substitution group
-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 () << ": "