From ebd204586d3d76d632113f5a98637a79e6c2050a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 22 Apr 2010 20:44:40 +0200 Subject: Don't copy default values for non-optional attributes --- xsd-frontend/parser.cxx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/xsd-frontend/parser.cxx b/xsd-frontend/parser.cxx index 1e3e076..0238a7b 100644 --- a/xsd-frontend/parser.cxx +++ b/xsd-frontend/parser.cxx @@ -410,6 +410,7 @@ namespace XSDFrontend { using SemanticGraph::Member; using SemanticGraph::Element; + using SemanticGraph::Attribute; try { @@ -482,7 +483,17 @@ namespace XSDFrontend if (ref.fixed_p ()) m.fixed (ref.value ()); else if (ref.default_p ()) - m.default_ (ref.value ()); + { + // Default value applies only if the attribute is optional. + // + if (Attribute* a = dynamic_cast (&m)) + { + if (a->optional_p ()) + m.default_ (ref.value ()); + } + else + m.default_ (ref.value ()); + } if (m.default_p ()) { @@ -4215,9 +4226,11 @@ namespace XSDFrontend // if (!node.default_p ()) { + // Default value applies only if this attribute is optional. + // if (prot.fixed_p ()) node.fixed (prot.value ()); - else if (prot.default_p ()) + else if (optional && prot.default_p ()) node.default_ (prot.value ()); if (node.default_p ()) -- cgit v1.1