+2006-11-09 Atsushi Enomoto <atsushi@ximian.com>
+
+ * 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 <atsushi@ximian.com>
* XmlSchemaImporter.cs : when top-level element is xs:anyType, all
void ImportAttributes (XmlQualifiedName typeQName, ClassMap cmap, XmlSchemaObjectCollection atts, XmlSchemaAnyAttribute anyat, CodeIdentifiers classIds)
{
+ atts = CollectAttributeUsesNonOverlap (atts, cmap);
+
if (anyat != null)
{
XmlTypeMapMemberAnyAttribute member = new XmlTypeMapMemberAnyAttribute ();
}
}
+ // 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)
}
else
{
- ns = typeQName.Namespace;
+ ns = attr.ParentIsSchema ? typeQName.Namespace : String.Empty;
return attr;
}
}
//
// Author:
// Gert Driesen (drieseng@users.sourceforge.net)
+// Atsushi Enomoto (atsushi@ximian.com)
//
-// (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;
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")));
+ }
}
}