Author: atsushi
Date: 2006-11-09 04:07:40 -0500 (Thu, 09 Nov 2006)
New Revision: 67581

Modified:
   trunk/mcs/class/System.XML/System.Xml.Serialization/ChangeLog
   trunk/mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs
   trunk/mcs/class/System.XML/Test/System.Xml.Serialization/ChangeLog
   
trunk/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSchemaImporterTests.cs
Log:
2006-11-09  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * XmlSchemaImporter.cs : attributes might overlap by extending
          base content models. Since invalid content models are rejected by
          Compile(), simply ignore duplicating attributes. Note that it is
          basically hack, which should not skip derived ones but use them (but
          it is mostly harmless since the result is very unlikely to differ).

        * XmlSchemaImporterTests.cs :
          added ImportComplexDerivationByExtension().



Modified: trunk/mcs/class/System.XML/System.Xml.Serialization/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/System.Xml.Serialization/ChangeLog       
2006-11-09 09:03:18 UTC (rev 67580)
+++ trunk/mcs/class/System.XML/System.Xml.Serialization/ChangeLog       
2006-11-09 09:07:40 UTC (rev 67581)
@@ -1,3 +1,11 @@
+2006-11-09  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * XmlSchemaImporter.cs : attributes might overlap by extending
+         base content models. Since invalid content models are rejected by
+         Compile(), simply ignore duplicating attributes. Note that it is
+         basically hack, which should not skip derived ones but use them (but
+         it is mostly harmless since the result is very unlikely to differ).
+
 2006-11-08  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * XmlSchemaImporter.cs : when top-level element is xs:anyType, all

Modified: 
trunk/mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs
===================================================================
--- trunk/mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs    
2006-11-09 09:03:18 UTC (rev 67580)
+++ trunk/mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs    
2006-11-09 09:07:40 UTC (rev 67581)
@@ -686,6 +686,8 @@
                
                void ImportAttributes (XmlQualifiedName typeQName, ClassMap 
cmap, XmlSchemaObjectCollection atts, XmlSchemaAnyAttribute anyat, 
CodeIdentifiers classIds)
                {
+                       atts = CollectAttributeUsesNonOverlap (atts, cmap);
+
                        if (anyat != null)
                        {
                        XmlTypeMapMemberAnyAttribute member = new 
XmlTypeMapMemberAnyAttribute ();
@@ -727,6 +729,20 @@
                        }
                }
 
+               // 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.
+               // Basically it should use
+               // XmlSchemaComplexType.AttributeUses.
+               XmlSchemaObjectCollection CollectAttributeUsesNonOverlap (
+                       XmlSchemaObjectCollection src, ClassMap map)
+               {
+                       XmlSchemaObjectCollection atts = new 
XmlSchemaObjectCollection ();
+                       foreach (XmlSchemaAttribute a in src)
+                               if (map.GetAttribute (a.QualifiedName.Name, 
a.QualifiedName.Namespace) == null)
+                                       atts.Add (a);
+                       return atts;
+               }
+
                ListMap BuildArrayMap (XmlQualifiedName typeQName, 
XmlSchemaComplexType stype, out TypeData arrayTypeData)
                {
                        if (encodedFormat)
@@ -1628,7 +1644,7 @@
                        }
                        else
                        {
-                               ns = typeQName.Namespace;
+                               ns = attr.ParentIsSchema ? typeQName.Namespace 
: String.Empty;
                                return attr;
                        }
                }

Modified: trunk/mcs/class/System.XML/Test/System.Xml.Serialization/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/Test/System.Xml.Serialization/ChangeLog  
2006-11-09 09:03:18 UTC (rev 67580)
+++ trunk/mcs/class/System.XML/Test/System.Xml.Serialization/ChangeLog  
2006-11-09 09:07:40 UTC (rev 67581)
@@ -1,3 +1,8 @@
+2006-11-09  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * XmlSchemaImporterTests.cs :
+         added ImportComplexDerivationByExtension().
+
 2006-11-08  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * XmlSchemaImporterTests.cs :

Modified: 
trunk/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSchemaImporterTests.cs
===================================================================
--- 
trunk/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSchemaImporterTests.cs
  2006-11-09 09:03:18 UTC (rev 67580)
+++ 
trunk/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSchemaImporterTests.cs
  2006-11-09 09:07:40 UTC (rev 67581)
@@ -3,10 +3,33 @@
 //
 // Author:
 //   Gert Driesen ([EMAIL PROTECTED])
+//   Atsushi Enomoto ([EMAIL PROTECTED])
 //
-// (C) 2005 Novell
+// (C) 2005 Gert Driesen
+// Copyright (C) 2006 Novell, Inc.
 // 
 
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
 using System;
 using System.CodeDom;
 using System.Collections;
@@ -1035,5 +1058,29 @@
                        Assert.IsTrue (foo, "FooType not found");
                        Assert.IsTrue (bar, "BarType not found");
                }
+
+               [Test]
+               public void ImportComplexDerivationByExtension ()
+               {
+                       string xsd = @"<xs:schema 
xmlns:xs='http://www.w3.org/2001/XMLSchema'>
+  <xs:element name='Root' type='DerivedType' />
+  <xs:complexType name='DerivedType'>
+    <xs:complexContent>
+      <xs:extension base='BaseType'>
+        <xs:attribute name='Foo' type='xs:string' />
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+  <xs:complexType name='BaseType'>
+    <xs:attribute name='Foo' type='xs:string' />
+  </xs:complexType>
+</xs:schema>";
+                       XmlSchemas xss = new XmlSchemas ();
+                       xss.Add (XmlSchema.Read (new XmlTextReader (new 
StringReader (xsd)), null));
+                       XmlSchemaImporter imp = new XmlSchemaImporter (xss);
+                       CodeNamespace cns = new CodeNamespace ();
+                       XmlCodeExporter exp = new XmlCodeExporter (cns);
+                       exp.ExportTypeMapping (imp.ImportTypeMapping (new 
XmlQualifiedName ("Root")));
+               }
        }
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to