aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-04-22 20:44:40 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-04-22 20:44:40 +0200
commitebd204586d3d76d632113f5a98637a79e6c2050a (patch)
tree3469a4d9b313a4e25eab43f423f35a2f91ed51e0
parent0ad1584d0ea2787ca1b6799855f3ad49e8fbf464 (diff)
Don't copy default values for non-optional attributes
-rw-r--r--xsd-frontend/parser.cxx17
1 files 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<Attribute*> (&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 ())