Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAtsushi Eno <atsushieno@veritas-vos-liberabit.com>2013-08-09 12:22:38 +0400
committerAtsushi Eno <atsushieno@veritas-vos-liberabit.com>2013-08-09 12:22:38 +0400
commitd21b0aa3d9c0bcf447de05cbc61868b69d1098ed (patch)
tree570fdb3c22517cb2e7aeca6e8b03cce0751f9a77 /mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs
parentfde407c873ba66a8ceb61595de7461b6a2426a2d (diff)
Fixed bug #4141 - XmlSchemaImporter needs to consider attributeGroupRef in some case.
Diffstat (limited to 'mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs')
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs22
1 files changed, 21 insertions, 1 deletions
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs
index fdcbc0e186f..0ea81302af1 100644
--- a/mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs
@@ -35,6 +35,7 @@ using System.CodeDom.Compiler;
#endif
using System.Xml.Schema;
using System.Collections;
+using System.Collections.Generic;
#if NET_2_0 && CONFIGURATION_DEP
using System.Configuration;
using System.Xml.Serialization.Configuration;
@@ -744,6 +745,25 @@ namespace System.Xml.Serialization
}
}
}
+
+ IEnumerable<XmlSchemaAttribute> EnumerateAttributes (XmlSchemaObjectCollection col, List<XmlSchemaAttributeGroup> recurse)
+ {
+ foreach (var o in col) {
+ if (o is XmlSchemaAttributeGroupRef) {
+ var gr = (XmlSchemaAttributeGroupRef) o;
+ var g = FindRefAttributeGroup (gr.RefName);
+ if (recurse.Contains (g))
+ continue;
+ recurse.Add (g);
+ if (g == null)
+ throw new InvalidOperationException (string.Format ("Referenced AttributeGroup '{0}' was not found.", gr.RefName));
+ foreach (var a in EnumerateAttributes (g.Attributes, recurse))
+ yield return a;
+ }
+ else
+ yield return (XmlSchemaAttribute) o;
+ }
+ }
// Attributes might be redefined, so there is an existing attribute for the same name, skip it.
// FIXME: this is nothing more than just a hack.
@@ -753,7 +773,7 @@ namespace System.Xml.Serialization
XmlSchemaObjectCollection src, ClassMap map)
{
XmlSchemaObjectCollection atts = new XmlSchemaObjectCollection ();
- foreach (XmlSchemaAttribute a in src)
+ foreach (var a in EnumerateAttributes (src, new List<XmlSchemaAttributeGroup> ()))
if (map.GetAttribute (a.QualifiedName.Name, a.QualifiedName.Namespace) == null)
atts.Add (a);
return atts;