* SerializationCodeGenerator.cs: Minor fixes.
authorLluis Sanchez <lluis@novell.com>
Thu, 4 Sep 2003 02:39:08 +0000 (02:39 -0000)
committerLluis Sanchez <lluis@novell.com>
Thu, 4 Sep 2003 02:39:08 +0000 (02:39 -0000)
* SoapReflectionImporter.cs: More fixes.
* SoapSchemaExporter.cs: implemented.
* SoapSchemaImporter.cs: Initial implementation.
* TypeTranslator.cs: new methods for dealing with encoded arrays: GetArrayName
  and ParseArrayType
* XmlCodeExporter.cs: Fix. When exporting a map, export all derived maps.
* XmlMemberMapping.cs: Minor fixes.
* XmlMembersMapping.cs: added some convenient constructors.
* XmlSchemaExporter.cs: Added support for encoded format.
* XmlSchemaImporter.cs: Added support for encoded format.
* XmlSerializationReader.cs: changed some string literals by constants.
  Implemented ParseWsdlArrayType.
* XmlSerializationReaderInterpreter.cs: Read typeArray attribute when serializing
  custom attributes.
* XmlSerializationWriter.cs: Implemented WriteXmlAttribute.
* XmlSerializationWriterInterpreter.cs: Use WriteXmlAttribute instead of
  WriteAttribute to write custom attributes.
* XmlSerializer.cs: added some namespace constants.
* XmlTypeMapping.cs: added GetSchemaArrayName method.

svn path=/trunk/mcs/; revision=17856

17 files changed:
mcs/class/System.XML/System.Xml.Serialization/ChangeLog
mcs/class/System.XML/System.Xml.Serialization/SerializationCodeGenerator.cs
mcs/class/System.XML/System.Xml.Serialization/SoapReflectionImporter.cs
mcs/class/System.XML/System.Xml.Serialization/SoapSchemaExporter.cs
mcs/class/System.XML/System.Xml.Serialization/SoapSchemaImporter.cs
mcs/class/System.XML/System.Xml.Serialization/TypeTranslator.cs
mcs/class/System.XML/System.Xml.Serialization/XmlCodeExporter.cs
mcs/class/System.XML/System.Xml.Serialization/XmlMemberMapping.cs
mcs/class/System.XML/System.Xml.Serialization/XmlMembersMapping.cs
mcs/class/System.XML/System.Xml.Serialization/XmlSchemaExporter.cs
mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs
mcs/class/System.XML/System.Xml.Serialization/XmlSerializationReader.cs
mcs/class/System.XML/System.Xml.Serialization/XmlSerializationReaderInterpreter.cs
mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriter.cs
mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriterInterpreter.cs
mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs
mcs/class/System.XML/System.Xml.Serialization/XmlTypeMapping.cs

index 174b3f2e3af8df96c19477be9d705c0d1429d6e0..03d933a0319fda28cc0eed64b33acd32b7bfa850 100755 (executable)
@@ -1,3 +1,26 @@
+2003-09-04  Lluis Sanchez Gual <lluis@ximian.com>
+
+       * SerializationCodeGenerator.cs: Minor fixes.
+       * SoapReflectionImporter.cs: More fixes.
+       * SoapSchemaExporter.cs: implemented.
+       * SoapSchemaImporter.cs: Initial implementation.
+       * TypeTranslator.cs: new methods for dealing with encoded arrays: GetArrayName
+         and ParseArrayType
+       * XmlCodeExporter.cs: Fix. When exporting a map, export all derived maps.
+       * XmlMemberMapping.cs: Minor fixes.
+       * XmlMembersMapping.cs: added some convenient constructors.
+       * XmlSchemaExporter.cs: Added support for encoded format.
+       * XmlSchemaImporter.cs: Added support for encoded format. 
+       * XmlSerializationReader.cs: changed some string literals by constants.
+         Implemented ParseWsdlArrayType.
+       * XmlSerializationReaderInterpreter.cs: Read typeArray attribute when serializing
+         custom attributes.
+       * XmlSerializationWriter.cs: Implemented WriteXmlAttribute.
+       * XmlSerializationWriterInterpreter.cs: Use WriteXmlAttribute instead of
+         WriteAttribute to write custom attributes.
+       * XmlSerializer.cs: added some namespace constants.
+       * XmlTypeMapping.cs: added GetSchemaArrayName method.
+
 2003-09-01  Lluis Sanchez Gual <lluis@ximian.com>
 
        * XmlSchemaImporter.cs: Implemented ImportMembersMapping.
index 3e705d5aff6fc2c8c1d39a375fef84b2b24f9d97..db0ddc15b36af5b2b0f20060d617dfc8b5b3c82d 100644 (file)
@@ -407,7 +407,7 @@ namespace System.Xml.Serialization
                
                                                string tmpVar2 = GetObTempVar ();
                                                WriteLineInd ("foreach (XmlAttribute " + tmpVar2 + " in " + tmpVar + ")");
-                                               WriteLine ("WriteAttribute (" + tmpVar2 + ".Prefix, " + tmpVar2 + ".LocalName, " + tmpVar2 + ".NamespaceURI, " + tmpVar2 + ".Value);");
+                                               WriteLine ("WriteXmlAttribute (" + tmpVar2 + ", " + ob + ");");
                                                Unindent ();
                                                WriteLineUni ("}");
                
@@ -576,7 +576,7 @@ namespace System.Xml.Serialization
                                else
                                        arrayType = GetLiteral (n);
                                
-                               WriteMetCall ("WriteAttribute", GetLiteral("arrayType"), GetLiteral(SoapReflectionImporter.EncodingNamespace), arrayType);
+                               WriteMetCall ("WriteAttribute", GetLiteral("arrayType"), GetLiteral(XmlSerializer.WsdlNamespace), arrayType);
                        }
                        GenerateWriteListContent (typeMap.TypeData, (ListMap) typeMap.ObjectMap, ob, false);
                }
@@ -1121,7 +1121,10 @@ namespace System.Xml.Serialization
                                if (anyAttrMember != null) 
                                {
                                        if (!GenerateReadArrayMemberHook (typeMap.TypeData.Type, anyAttrMember, "anyAttributeIndex")) {
-                                               GenerateAddListValue (anyAttrMember.TypeData, "anyAttributeArray", "anyAttributeIndex", GetCast (anyAttrMember.TypeData.ListItemTypeData, "Document.ReadNode(Reader)"), true);
+                                               WriteLine ("System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute) Document.ReadNode(Reader);");
+                                               if (typeof(System.Xml.Schema.XmlSchemaAnnotated).IsAssignableFrom (typeMap.TypeData.Type)) 
+                                                       WriteLine ("ParseWsdlArrayType (attr);");
+                                               GenerateAddListValue (anyAttrMember.TypeData, "anyAttributeArray", "anyAttributeIndex", GetCast (anyAttrMember.TypeData.ListItemTypeData, "attr"), true);
                                                GenerateEndHook ();
                                        }
                                        WriteLine ("anyAttributeIndex++;");
index 52f49813366abab20835f60b87d2cddcc19754a1..e702c28b57d7dac53d7af9d7d54555fc525b62d4 100644 (file)
@@ -20,7 +20,6 @@ namespace System.Xml.Serialization {
                ArrayList includedTypes;
                ArrayList relatedMaps = new ArrayList ();
                ReflectionHelper helper = new ReflectionHelper();
-               internal const string EncodingNamespace = "http://schemas.xmlsoap.org/soap/encoding/";
 
                #region Constructors
 
@@ -188,13 +187,13 @@ namespace System.Xml.Serialization {
                        if (type == typeof (object) && includedTypes != null)
                        {
                                foreach (Type intype in includedTypes)
-                                       map.DerivedTypes.Add (ImportTypeMapping (intype));
+                                       map.DerivedTypes.Add (ImportTypeMapping (intype, defaultNamespace));
                        }
 
                        // Register this map as a derived class of object
 
                        if (typeData.Type != typeof(object))
-                               ImportTypeMapping (typeof(object)).DerivedTypes.Add (map);
+                               ImportTypeMapping (typeof(object), defaultNamespace).DerivedTypes.Add (map);
                        
                        if (type.BaseType != null && type.BaseType != typeof(object))
                                map.BaseMap = ImportClassMapping (type.BaseType, defaultNamespace);
@@ -230,22 +229,21 @@ namespace System.Xml.Serialization {
                XmlTypeMapping ImportListMapping (Type type, string defaultNamespace)
                {
                        TypeData typeData = TypeTranslator.GetTypeData (type);
-                       XmlTypeMapping map = helper.GetRegisteredClrType (type, EncodingNamespace);
+                       XmlTypeMapping map = helper.GetRegisteredClrType (type, XmlSerializer.EncodingNamespace);
                        if (map != null) return map;
 
                        ListMap obmap = new ListMap ();
+                       TypeData itemTypeData = typeData.ListItemTypeData;
 
-                       map = CreateTypeMapping (typeData, "Array", EncodingNamespace);
-                       helper.RegisterClrType (map, type, EncodingNamespace);
+                       map = CreateTypeMapping (typeData, "Array", XmlSerializer.EncodingNamespace);
+                       helper.RegisterClrType (map, type, XmlSerializer.EncodingNamespace);
                        map.MultiReferenceType = true;
                        map.ObjectMap = obmap;
 
-                       Type itemType = typeData.ListItemType;
-                       TypeData itemTypeData = TypeTranslator.GetTypeData (itemType);
                        XmlTypeMapElementInfo elem = new XmlTypeMapElementInfo (null, itemTypeData);
                        
                        if (elem.TypeData.IsComplexType) {
-                               elem.MappedType = ImportTypeMapping (itemType);
+                               elem.MappedType = ImportTypeMapping (typeData.ListItemType, defaultNamespace);
                                elem.TypeData = elem.MappedType.TypeData;
                        }
                                
@@ -257,7 +255,7 @@ namespace System.Xml.Serialization {
                        list.Add (elem);
 
                        obmap.ItemInfo = list;
-                       ImportTypeMapping (typeof(object)).DerivedTypes.Add (map);
+                       ImportTypeMapping (typeof(object), defaultNamespace).DerivedTypes.Add (map);
 
                        return map;
                }
@@ -294,7 +292,7 @@ namespace System.Xml.Serialization {
 
                        bool isFlags = type.GetCustomAttributes (typeof(FlagsAttribute),false).Length > 0;
                        map.ObjectMap = new EnumMap (members, isFlags);
-                       ImportTypeMapping (typeof(object)).DerivedTypes.Add (map);
+                       ImportTypeMapping (typeof(object), defaultNamespace).DerivedTypes.Add (map);
                        return map;
                }
 
@@ -345,7 +343,7 @@ namespace System.Xml.Serialization {
 
                                mapAttribute.Namespace = (atts.SoapAttribute.Namespace != null) ? atts.SoapAttribute.Namespace : "";
                                if (typeData.IsComplexType)
-                                       mapAttribute.MappedType = ImportTypeMapping (typeData.Type);
+                                       mapAttribute.MappedType = ImportTypeMapping (typeData.Type, defaultNamespace);
 
                                typeData = TypeTranslator.GetTypeData (rmember.MemberType, atts.SoapAttribute.DataType);
                                mapMember = mapAttribute;
@@ -366,7 +364,7 @@ namespace System.Xml.Serialization {
                                elem.Namespace = string.Empty;
                                elem.IsNullable = (atts.SoapElement != null) ? atts.SoapElement.IsNullable : false;
                                if (typeData.IsComplexType)
-                                       elem.MappedType = ImportTypeMapping (typeData.Type);
+                                       elem.MappedType = ImportTypeMapping (typeData.Type, defaultNamespace);
                                
                                infoList.Add (elem);
                                ((XmlTypeMapMemberElement)mapMember).ElementInfo = infoList;
index f11cbe45d47888b9e28fb64a94d16b0ec1fc335c..6c1c8a5ddd2128e84fc57dba22ae1eb1894550df 100644 (file)
@@ -3,6 +3,7 @@
 //
 // Authors:
 //     Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//     Lluis Sanchez Gual (lluis@ximian.com)
 //
 // (c) 2002 Ximian, Inc. (http://www.ximian.com)
 //
@@ -13,16 +14,16 @@ namespace System.Xml.Serialization
 {
        public class SoapSchemaExporter
        {
-               [MonoTODO]
+               XmlSchemaExporter _exporter;
+               
                public SoapSchemaExporter (XmlSchemas schemas)
                {
-                       throw new NotImplementedException ();
+                       _exporter = new XmlSchemaExporter(schemas, true);
                }
 
-               [MonoTODO]
                public void ExportMembersMapping (XmlMembersMapping xmlMembersMapping)
                {
-                       throw new NotImplementedException ();
+                       _exporter.ExportMembersMapping (xmlMembersMapping);
                }
 
                [MonoTODO]
@@ -32,11 +33,9 @@ namespace System.Xml.Serialization
                        throw new NotImplementedException ();
                }
 
-               [MonoTODO]
                public void ExportTypeMapping (XmlTypeMapping xmlTypeMapping)
                {
-                       throw new NotImplementedException ();
+                       _exporter.ExportTypeMapping (xmlTypeMapping);
                }
        }
 }
-
index baafb07716d433c568f0983aa60db4343ae8a0b8..d3b4dafa992750a9539cc52ac6e97f77c1babd3a 100644 (file)
@@ -14,8 +14,7 @@ namespace System.Xml.Serialization {
 \r
                #region Fields\r
 \r
-               XmlSchemas schemas;\r
-               CodeIdentifiers typeIdentifiers;\r
+               XmlSchemaImporter _importer;\r
 \r
                #endregion\r
 \r
@@ -23,13 +22,14 @@ namespace System.Xml.Serialization {
 \r
                public SoapSchemaImporter (XmlSchemas schemas)\r
                {\r
-                       this.schemas = schemas;\r
+                       _importer = new XmlSchemaImporter (schemas);\r
+                       _importer.UseEncodedFormat = true;\r
                }\r
 \r
                public SoapSchemaImporter (XmlSchemas schemas, CodeIdentifiers typeIdentifiers)\r
-                       : this (schemas)\r
                {\r
-                       this.typeIdentifiers = typeIdentifiers;\r
+                       _importer = new XmlSchemaImporter (schemas, typeIdentifiers);\r
+                       _importer.UseEncodedFormat = true;\r
                }\r
 \r
                #endregion // Constructors\r
@@ -68,4 +68,4 @@ namespace System.Xml.Serialization {
 \r
                #endregion // Methods\r
        }\r
-}\r
+}
index 3cedcfc45006153e5f58ed3c495f34d44072c46d..e494081a1a960b863ed2a44dbfa13c338aa51394 100644 (file)
@@ -150,6 +150,25 @@ namespace System.Xml.Serialization
                {
                        return "ArrayOf" + Char.ToUpper (elemName [0]) + elemName.Substring (1);
                }
+               
+               public static string GetArrayName (string elemName, int dimensions)
+               {
+                       string aname = GetArrayName (elemName);
+                       for ( ; dimensions > 1; dimensions--)
+                               aname = "ArrayOf" + aname;
+                       return aname;
+               }
+               
+               public static void ParseArrayType (string arrayType, out string type, out string ns, out string dimensions)
+               {
+                       int i = arrayType.LastIndexOf (":");
+                       if (i == -1) ns = "";
+                       else ns = arrayType.Substring (0,i);
+                       
+                       int j = arrayType.IndexOf ("[", i+1);
+                       if (j == -1) throw new InvalidOperationException ("Cannot parse WSDL array type: " + arrayType);
+                       type = arrayType.Substring (i+1, j-i-1);
+                       dimensions = arrayType.Substring (j);
+               }
        }
 }
-
index bfc9837d85dd1b90aa97103b1ac3a8b0db00693c..45c2ccb4f70868de693b24eac12c21ebc34dd53a 100644 (file)
@@ -135,12 +135,18 @@ namespace System.Xml.Serialization {
                                ExportMapCode (map.BaseMap, false);\r
                        }\r
 \r
+                       ExportDerivedTypes (map, codeClass);\r
+               }\r
+               \r
+               void ExportDerivedTypes (XmlTypeMapping map, CodeTypeDeclaration codeClass)\r
+               {\r
                        foreach (XmlTypeMapping tm in map.DerivedTypes)\r
                        {\r
                                CodeAttributeDeclaration iatt = new CodeAttributeDeclaration ("System.Xml.Serialization.XmlInclude");\r
                                iatt.Arguments.Add (new CodeAttributeArgument (new CodeTypeOfExpression(tm.TypeData.FullTypeName)));\r
                                AddCustomAttribute (codeClass, iatt, true);\r
                                ExportMapCode (tm, false);\r
+                               ExportDerivedTypes (tm, codeClass);\r
                        }\r
                }\r
 \r
@@ -447,4 +453,4 @@ namespace System.Xml.Serialization {
 \r
                #endregion // Methods\r
        }\r
-}\r
+}
index 5ef4c3ebf02bdca276274bede20fb0ac7107e41f..ed04825d5669e0cf3abda8f2ada6d4aa4c6cdc67 100644 (file)
@@ -29,22 +29,19 @@ namespace System.Xml.Serialization
                                _elementName = info.ElementName;
                                _namespace = info.Namespace;
                                if (info.MappedType != null) _typeNamespace = info.MappedType.Namespace;
-                               else _namespace = "";
+                               else _typeNamespace = "";
                        }
                        else
                        {
                                _elementName = _memberName;
                                _namespace = "";
                        }
-
-                       if (_typeNamespace == null) _typeNamespace = _namespace;
                }
 
                #region Properties
 
-               public bool Any {       
-                       [MonoTODO]
-                       get { return false; }
+               public bool Any {
+                       get { return _mapMember is XmlTypeMapMemberAnyElement; }
                }
 
                public string ElementName {     
index 44440f7ae53b7757ba6927071f71b5a38568567d..478bc938aea5253dd35655359655d3aa018da211 100644 (file)
@@ -22,6 +22,14 @@ namespace System.Xml.Serialization {
                {
                }
 
+               internal XmlMembersMapping (XmlMemberMapping[] mapping): this ("", null, false, mapping)
+               {
+               }
+
+               internal XmlMembersMapping (string elementName, string ns, XmlMemberMapping[] mapping): this (elementName, ns, true, mapping)
+               {
+               }
+
                internal XmlMembersMapping (string elementName, string ns, bool hasWrapperElement, XmlMemberMapping[] mapping)
                {
                        _elementName = elementName;
index 50a9555da4f5b17fcbe2de3773079c4afd0869d7..5f05894f681c42d188c08450a8a72173eb5d4251 100644 (file)
@@ -19,6 +19,8 @@ namespace System.Xml.Serialization {
 
                XmlSchemas schemas;
                Hashtable exportedMaps = new Hashtable();
+               bool encodedFormat = false;
+               XmlDocument xmlDoc;
                
                #endregion
 
@@ -29,6 +31,12 @@ namespace System.Xml.Serialization {
                        this.schemas = schemas;
                }
 
+               internal XmlSchemaExporter (XmlSchemas schemas, bool encodedFormat)
+               {
+                       this.encodedFormat = encodedFormat;
+                       this.schemas = schemas;
+               }
+
                #endregion // Constructors
 
                #region Methods
@@ -42,21 +50,41 @@ namespace System.Xml.Serialization {
                public void ExportMembersMapping (XmlMembersMapping xmlMembersMapping)
                {
                        XmlSchema schema = GetSchema (xmlMembersMapping.Namespace);
+                       ClassMap cmap = (ClassMap) xmlMembersMapping.ObjectMap;
 
-                       XmlSchemaElement selem = new XmlSchemaElement ();
-                       selem.Name = xmlMembersMapping.ElementName;
-                       schema.Items.Add (selem);
-
-                       XmlSchemaComplexType stype = new XmlSchemaComplexType ();
-
-                       XmlSchemaSequence particle;
-                       XmlSchemaAnyAttribute anyAttribute;
-                       ExportMembersMapSchema (schema, (ClassMap)xmlMembersMapping.ObjectMap, null, stype.Attributes, out particle, out anyAttribute);
-                       stype.Particle = particle;
-                       stype.AnyAttribute = anyAttribute;
-
-                       selem.SchemaType = stype;
-
+                       if (xmlMembersMapping.HasWrapperElement)
+                       {
+                               XmlSchemaElement selem = new XmlSchemaElement ();
+                               selem.Name = xmlMembersMapping.ElementName;
+                               schema.Items.Add (selem);
+       
+                               XmlSchemaComplexType stype = new XmlSchemaComplexType ();
+       
+                               XmlSchemaSequence particle;
+                               XmlSchemaAnyAttribute anyAttribute;
+                               ExportMembersMapSchema (schema, cmap, null, stype.Attributes, out particle, out anyAttribute);
+                               stype.Particle = particle;
+                               stype.AnyAttribute = anyAttribute;
+       
+                               selem.SchemaType = stype;
+                       }
+                       else
+                       {
+                               ICollection members = cmap.ElementMembers;
+                               if (members != null)
+                               {
+                                       foreach (XmlTypeMapMemberElement member in members)
+                                       {
+                                               Type memType = member.GetType();
+                                               if (member is XmlTypeMapMemberFlatList)
+                                                       throw new InvalidOperationException ("Unwrapped arrays not supported as parameters");
+                                               else if (memType == typeof(XmlTypeMapMemberElement))
+                                                       AddSchemaElement (schema.Items, schema, (XmlTypeMapElementInfo) member.ElementInfo [0], member.DefaultValue, false);
+                                               else
+                                                       AddSchemaElement (schema.Items, schema, (XmlTypeMapElementInfo) member.ElementInfo [0], false);
+                                       }
+                               }
+                       }
                        CompileSchemas ();
                }
 
@@ -68,13 +96,18 @@ namespace System.Xml.Serialization {
 
                public void ExportTypeMapping (XmlTypeMapping xmlTypeMapping)
                {
-                       XmlSchema schema = GetSchema (xmlTypeMapping.Namespace);
-                       XmlTypeMapElementInfo einfo = new XmlTypeMapElementInfo (null, xmlTypeMapping.TypeData);
-                       einfo.Namespace = xmlTypeMapping.Namespace;
-                       einfo.ElementName = xmlTypeMapping.ElementName;
-                       einfo.MappedType = xmlTypeMapping;
-                       einfo.IsNullable = false;
-                       AddSchemaElement (schema.Items, schema, einfo, false);
+                       if (encodedFormat)
+                               ExportClassSchema (xmlTypeMapping);
+                       else
+                       {
+                               XmlSchema schema = GetSchema (xmlTypeMapping.Namespace);
+                               XmlTypeMapElementInfo einfo = new XmlTypeMapElementInfo (null, xmlTypeMapping.TypeData);
+                               einfo.Namespace = xmlTypeMapping.Namespace;
+                               einfo.ElementName = xmlTypeMapping.ElementName;
+                               einfo.MappedType = xmlTypeMapping;
+                               einfo.IsNullable = false;
+                               AddSchemaElement (schema.Items, schema, einfo, false);
+                       }
                        CompileSchemas ();
                }
 
@@ -154,10 +187,6 @@ namespace System.Xml.Serialization {
                                        {
                                                AddSchemaArrayElement (seq.Items, schema, member.ElementInfo);
                                        }
-                                       else if (memType == typeof(XmlTypeMapMemberAnyAttribute))
-                                       {
-                                               // Ignore
-                                       }
                                        else if (memType == typeof(XmlTypeMapMemberElement))
                                        {
                                                XmlSchemaElement selem = (XmlSchemaElement) AddSchemaElement (seq.Items, schema, (XmlTypeMapElementInfo) member.ElementInfo [0], member.DefaultValue, true);
@@ -198,7 +227,7 @@ namespace System.Xml.Serialization {
                        ImportNamespace (currentSchema, attinfo.Namespace);
 
                        XmlSchema memberSchema = GetSchema (attinfo.Namespace);
-                       if (currentSchema == memberSchema)
+                       if (currentSchema == memberSchema || encodedFormat)
                        {
                                sat.Name = attinfo.AttributeName;
                                if (attinfo.TypeData.SchemaType == SchemaTypes.Enum)
@@ -247,15 +276,21 @@ namespace System.Xml.Serialization {
                        {
                                selem.MaxOccurs = 1;
                                selem.MinOccurs = einfo.IsNullable ? 1 : 0;
-                               if (einfo.TypeData.Type.IsPrimitive && einfo.TypeData.Type != typeof(string) ||
-                                       einfo.TypeData.Type.IsEnum) 
+                               
+                               if ((einfo.TypeData.Type.IsPrimitive && einfo.TypeData.Type != typeof(string)) ||
+                                       einfo.TypeData.Type.IsEnum || encodedFormat) 
                                        selem.MinOccurs = 1;
                        }
 
-                       XmlSchema memberSchema = GetSchema (einfo.Namespace);
-                       ImportNamespace (currentSchema, einfo.Namespace);
+                       XmlSchema memberSchema = null;
+                       
+                       if (!encodedFormat)
+                       {
+                               memberSchema = GetSchema (einfo.Namespace);
+                               ImportNamespace (currentSchema, einfo.Namespace);
+                       }               
 
-                       if (currentSchema == memberSchema)
+                       if (currentSchema == memberSchema || encodedFormat)
                        {
                                if (isTypeMember) selem.IsNillable = einfo.IsNullable;
                                selem.Name = einfo.ElementName;
@@ -281,17 +316,19 @@ namespace System.Xml.Serialization {
                                                break;
 
                                        case SchemaTypes.Array: 
-                                               selem.SchemaTypeName = new XmlQualifiedName (einfo.MappedType.XmlType, einfo.MappedType.XmlTypeNamespace);;
-                                               ImportNamespace (currentSchema, einfo.MappedType.XmlTypeNamespace);
-                                               ExportArraySchema (einfo.MappedType); 
+                                               XmlQualifiedName atypeName = ExportArraySchema (einfo.MappedType, currentSchema.TargetNamespace); 
+                                               selem.SchemaTypeName = atypeName;
+                                               ImportNamespace (currentSchema, atypeName.Namespace);
                                                break;
 
                                        case SchemaTypes.Class:
                                                if (einfo.MappedType.TypeData.Type != typeof(object)) {
-                                                       selem.SchemaTypeName = new XmlQualifiedName (einfo.MappedType.XmlType, einfo.MappedType.XmlTypeNamespace);;
+                                                       selem.SchemaTypeName = new XmlQualifiedName (einfo.MappedType.XmlType, einfo.MappedType.XmlTypeNamespace);
                                                        ImportNamespace (currentSchema, einfo.MappedType.XmlTypeNamespace);
                                                        ExportClassSchema (einfo.MappedType);
                                                }
+                                               else if (encodedFormat)
+                                                       selem.SchemaTypeName = new XmlQualifiedName (einfo.MappedType.XmlType, einfo.MappedType.XmlTypeNamespace);
                                                break;
 
                                        case SchemaTypes.Primitive:
@@ -309,7 +346,7 @@ namespace System.Xml.Serialization {
 
                void ImportNamespace (XmlSchema schema, string ns)
                {
-                       if (ns == "" || ns == schema.TargetNamespace) return;
+                       if (ns == "" || ns == schema.TargetNamespace || ns == XmlSchema.Namespace) return;
 
                        foreach (XmlSchemaObject sob in schema.Includes)
                                if ((sob is XmlSchemaImport) && ((XmlSchemaImport)sob).Namespace == ns) return;
@@ -412,23 +449,70 @@ namespace System.Xml.Serialization {
                        stype.Content = rest;
                }
 
-               void ExportArraySchema (XmlTypeMapping map)
+               XmlQualifiedName ExportArraySchema (XmlTypeMapping map, string defaultNamespace)
                {
-                       if (IsMapExported (map)) return;
-                       SetMapExported (map);
-
-                       XmlSchema schema = GetSchema (map.Namespace);
-                       XmlSchemaComplexType stype = new XmlSchemaComplexType ();
-                       stype.Name = map.ElementName;
-                       schema.Items.Add (stype);
-
                        ListMap lmap = (ListMap) map.ObjectMap;
-                       XmlSchemaSequence seq = new XmlSchemaSequence ();
-                       XmlSchemaParticle spart = AddSchemaArrayElement (seq.Items, schema, lmap.ItemInfo);
-                       if (spart is XmlSchemaChoice)
-                               stype.Particle = spart;
+
+                       if (encodedFormat)
+                       {
+                               string name, ns, schemaNs;
+                               lmap.GetArrayType (-1, out name, out ns);                               
+                               if (ns == XmlSchema.Namespace) schemaNs = defaultNamespace;
+                               else schemaNs = ns;
+
+                               if (IsMapExported (map)) return new XmlQualifiedName (lmap.GetSchemaArrayName (), schemaNs);
+                               SetMapExported (map);
+
+                               XmlSchema schema = GetSchema (schemaNs);
+                               XmlSchemaComplexType stype = new XmlSchemaComplexType ();
+                               stype.Name = lmap.GetSchemaArrayName ();
+                               schema.Items.Add (stype);
+                               
+                               XmlSchemaComplexContent content = new XmlSchemaComplexContent();
+                               content.IsMixed = false;
+                               stype.ContentModel = content;
+                               
+                               XmlSchemaComplexContentRestriction rest = new XmlSchemaComplexContentRestriction ();
+                               content.Content = rest;
+                               rest.BaseTypeName = new XmlQualifiedName ("Array", XmlSerializer.EncodingNamespace);
+                               XmlSchemaAttribute at = new XmlSchemaAttribute ();
+                               rest.Attributes.Add (at);
+                               at.RefName = new XmlQualifiedName ("arrayType", XmlSerializer.EncodingNamespace);
+                               
+                               XmlAttribute arrayType = Document.CreateAttribute ("arrayType", XmlSerializer.WsdlNamespace);
+                               arrayType.Value = ns + (ns != "" ? ":" : "") + name;
+                               at.UnhandledAttributes = new XmlAttribute [] { arrayType };
+                               
+                               return new XmlQualifiedName (lmap.GetSchemaArrayName (), schemaNs);
+                       }
                        else
-                               stype.Particle = seq;
+                       {
+                               if (IsMapExported (map)) return new XmlQualifiedName (map.XmlType, map.XmlTypeNamespace);
+                               
+                               SetMapExported (map);
+                               XmlSchema schema = GetSchema (map.Namespace);
+                               XmlSchemaComplexType stype = new XmlSchemaComplexType ();
+                               stype.Name = map.ElementName;
+                               schema.Items.Add (stype);
+
+                               XmlSchemaSequence seq = new XmlSchemaSequence ();
+                               XmlSchemaParticle spart = AddSchemaArrayElement (seq.Items, schema, lmap.ItemInfo);
+                               if (spart is XmlSchemaChoice)
+                                       stype.Particle = spart;
+                               else
+                                       stype.Particle = seq;
+                                       
+                               return new XmlQualifiedName (map.XmlType, map.XmlTypeNamespace);
+                       }
+               }
+               
+               XmlDocument Document
+               {
+                       get
+                       {
+                               if (xmlDoc == null) xmlDoc = new XmlDocument ();
+                               return xmlDoc;
+                       }
                }
 
                bool IsMapExported (XmlTypeMapping map)
@@ -456,7 +540,8 @@ namespace System.Xml.Serialization {
                        {
                                schema = new XmlSchema ();
                                schema.TargetNamespace = ns;
-                               schema.ElementFormDefault = XmlSchemaForm.Qualified;
+                               if (!encodedFormat)
+                                       schema.ElementFormDefault = XmlSchemaForm.Qualified;
                                schemas.Add (schema);
                        }
                        return schema;
index 93155c1232a5ade83559924dc2f616f46620d880..d3d29b18706c025a05ff20fc7982524dcd0344a2 100644 (file)
@@ -24,8 +24,12 @@ namespace System.Xml.Serialization {
                Hashtable dataMappedTypes = new Hashtable ();\r
                Queue pendingMaps = new Queue ();\r
                Hashtable sharedAnonymousTypes = new Hashtable ();\r
+               bool encodedFormat = false;\r
 \r
                static readonly XmlQualifiedName anyType = new XmlQualifiedName ("anyType",XmlSchema.Namespace);\r
+               static readonly XmlQualifiedName arrayType = new XmlQualifiedName ("Array",XmlSerializer.EncodingNamespace);\r
+               static readonly XmlQualifiedName arrayTypeAttribute = new XmlQualifiedName ("arrayType",XmlSerializer.WsdlNamespace);\r
+               \r
                XmlSchemaElement anyElement = null;\r
 \r
                class MapFixup\r
@@ -50,6 +54,12 @@ namespace System.Xml.Serialization {
                {\r
                        this.typeIdentifiers = typeIdentifiers;\r
                }\r
+               \r
+               internal bool UseEncodedFormat\r
+               {\r
+                       get { return encodedFormat; }\r
+                       set { encodedFormat = value; }\r
+               }\r
 \r
                #endregion // Constructors\r
 \r
@@ -113,18 +123,36 @@ namespace System.Xml.Serialization {
                        CodeIdentifiers classIds = new CodeIdentifiers ();\r
                        ImportParticleComplexContent (name, cmap, seq, classIds, false);\r
 \r
+                       BuildPendingMaps ();\r
+\r
                        int n = 0;\r
                        XmlMemberMapping[] mapping = new XmlMemberMapping [cmap.AllMembers.Count];\r
                        foreach (XmlTypeMapMember mapMem in cmap.AllMembers)\r
                                mapping[n++] = new XmlMemberMapping (mapMem.Name, mapMem);\r
-                               \r
-                       return new XmlMembersMapping (name.Name, name.Namespace, true, mapping);\r
+                       \r
+                       return new XmlMembersMapping (name.Name, name.Namespace, mapping);\r
                }\r
 \r
-               [MonoTODO]\r
                public XmlMembersMapping ImportMembersMapping (XmlQualifiedName[] names)\r
                {\r
-                       throw new NotImplementedException ();\r
+                       XmlMemberMapping[] mapping = new XmlMemberMapping [names.Length];\r
+                       for (int n=0; n<names.Length; n++)\r
+                       {\r
+                               XmlSchemaElement elem = (XmlSchemaElement) schemas.Find (names[n], typeof (XmlSchemaElement));\r
+                               if (elem == null) throw new InvalidOperationException ("Schema element '" + names[n] + "' not found");\r
+                               \r
+                               XmlQualifiedName typeQName = new XmlQualifiedName ("Message", names[n].Namespace);\r
+                               TypeData td = GetElementTypeData (typeQName, elem);\r
+                               \r
+                               XmlTypeMapMemberElement mapMem = new XmlTypeMapMemberElement ();\r
+                               mapMem.Name = elem.Name;\r
+                               mapMem.TypeData = td;\r
+                               mapMem.ElementInfo.Add (CreateElementInfo (typeQName.Namespace, mapMem, elem.Name, td, true));\r
+                               \r
+                               mapping[n] = new XmlMemberMapping (mapMem.Name, mapMem);\r
+                       }\r
+                       BuildPendingMaps ();\r
+                       return new XmlMembersMapping (mapping);\r
                }\r
 \r
                [MonoTODO]\r
@@ -175,6 +203,14 @@ namespace System.Xml.Serialization {
 \r
                        XmlSchemaType type = (XmlSchemaType) schemas.Find (name, typeof (XmlSchemaComplexType));\r
                        if (type == null) type = (XmlSchemaType) schemas.Find (name, typeof (XmlSchemaSimpleType));\r
+                       \r
+                       if (type == null) \r
+                       {\r
+                               if (name.Namespace == XmlSerializer.EncodingNamespace)\r
+                                       throw new InvalidOperationException ("Referenced type '" + name + "' valid only for encoded SOAP");\r
+                               else\r
+                                       throw new InvalidOperationException ("Referenced type '" + name + "' not found");\r
+                       }\r
 \r
                        return ImportType (name, type, root);\r
                }\r
@@ -292,8 +328,9 @@ namespace System.Xml.Serialization {
                        }\r
 \r
                        ImportAttributes (typeQName, cmap, stype.Attributes, stype.AnyAttribute, classIds);\r
+                       ImportExtensionTypes (typeQName);\r
                }\r
-\r
+               \r
                void ImportAttributes (XmlQualifiedName typeQName, ClassMap cmap, XmlSchemaObjectCollection atts, XmlSchemaAnyAttribute anyat, CodeIdentifiers classIds)\r
                {\r
                        if (anyat != null)\r
@@ -334,21 +371,95 @@ namespace System.Xml.Serialization {
 \r
                ListMap BuildArrayMap (XmlQualifiedName typeQName, XmlSchemaComplexType stype, out TypeData arrayTypeData)\r
                {\r
-                       ClassMap cmap = new ClassMap ();\r
-                       CodeIdentifiers classIds = new CodeIdentifiers();\r
-                       ImportParticleComplexContent (typeQName, cmap, stype.Particle, classIds, false);\r
+                       if (encodedFormat)\r
+                       {\r
+                               XmlSchemaComplexContent content = stype.ContentModel as XmlSchemaComplexContent;\r
+                               XmlSchemaComplexContentRestriction rest = content.Content as XmlSchemaComplexContentRestriction;\r
+                               XmlSchemaAttribute arrayTypeAt = FindArrayAttribute (rest.Attributes);\r
+                               \r
+                               XmlAttribute[] uatts = arrayTypeAt.UnhandledAttributes;\r
+                               if (uatts == null || uatts.Length == 0) throw new InvalidOperationException ("arrayType attribute not specified in array declaration: " + typeQName);\r
+                               \r
+                               XmlAttribute xat = null;\r
+                               foreach (XmlAttribute at in uatts)\r
+                                       if (at.LocalName == "arrayType" && at.NamespaceURI == XmlSerializer.WsdlNamespace)\r
+                                               { xat = at; break; }\r
+                               \r
+                               if (xat == null) \r
+                                       throw new InvalidOperationException ("arrayType attribute not specified in array declaration: " + typeQName);\r
 \r
-                       XmlTypeMapMemberFlatList list = (cmap.AllMembers.Count == 1) ? cmap.AllMembers[0] as XmlTypeMapMemberFlatList : null;\r
-                       if (list != null && list.ChoiceMember == null)\r
+                               string name, ns, dims;\r
+                               TypeTranslator.ParseArrayType (xat.Value, out name, out ns, out dims);\r
+                               \r
+                               return BuildEncodedArrayMap (name + dims, ns, out arrayTypeData);\r
+                       }\r
+                       else\r
                        {\r
-                               arrayTypeData = list.TypeData;\r
-                               return list.ListMap;\r
+                               ClassMap cmap = new ClassMap ();\r
+                               CodeIdentifiers classIds = new CodeIdentifiers();\r
+                               ImportParticleComplexContent (typeQName, cmap, stype.Particle, classIds, false);\r
+       \r
+                               XmlTypeMapMemberFlatList list = (cmap.AllMembers.Count == 1) ? cmap.AllMembers[0] as XmlTypeMapMemberFlatList : null;\r
+                               if (list != null && list.ChoiceMember == null)\r
+                               {\r
+                                       arrayTypeData = list.TypeData;\r
+                                       return list.ListMap;\r
+                               }\r
+                               else\r
+                               {\r
+                                       arrayTypeData = null;\r
+                                       return null;\r
+                               }\r
+                       }\r
+               }\r
+               \r
+               ListMap BuildEncodedArrayMap (string type, string ns, out TypeData arrayTypeData)\r
+               {\r
+                       ListMap map = new ListMap ();\r
+                       \r
+                       int i = type.LastIndexOf ("[");\r
+                       if (i == -1) throw new InvalidOperationException ("Invalid arrayType value: " + type);\r
+                       if (type.IndexOf (",",i) != -1) throw new InvalidOperationException ("Multidimensional arrays are not supported");\r
+                       \r
+                       string itemType = type.Substring (0,i);\r
+                       \r
+                       TypeData itemTypeData;\r
+                       if (itemType.IndexOf ("[") != -1) \r
+                       {\r
+                               ListMap innerListMap = BuildEncodedArrayMap (itemType, ns, out itemTypeData);\r
+                               \r
+                               int dims = itemType.Split ('[').Length - 1;\r
+                               string name = TypeTranslator.GetArrayName (type, dims);\r
+                               XmlQualifiedName qname = new XmlQualifiedName (name, ns);\r
+                               XmlTypeMapping tmap = CreateArrayTypeMapping (qname, itemTypeData);\r
+                               tmap.ObjectMap = innerListMap;\r
                        }\r
                        else\r
                        {\r
-                               arrayTypeData = null;\r
-                               return null;\r
+                               itemTypeData = GetTypeData (new XmlQualifiedName (itemType, ns), null);\r
+                       }\r
+                       \r
+                       arrayTypeData = itemTypeData.ListTypeData;\r
+                       map.ItemInfo.Add (CreateElementInfo ("", null, "Item", itemTypeData, true));\r
+                       return map;\r
+               }\r
+               \r
+               XmlSchemaAttribute FindArrayAttribute (XmlSchemaObjectCollection atts)\r
+               {\r
+                       foreach (object ob in atts)\r
+                       {\r
+                               XmlSchemaAttribute att = ob as XmlSchemaAttribute;\r
+                               if (att != null && att.RefName == arrayTypeAttribute) return att;\r
+                               \r
+                               XmlSchemaAttributeGroupRef gref = ob as XmlSchemaAttributeGroupRef;\r
+                               if (gref != null)\r
+                               {\r
+                                       XmlSchemaAttributeGroup grp = (XmlSchemaAttributeGroup) schemas.Find (gref.RefName, typeof(XmlSchemaAttributeGroup));\r
+                                       att = FindArrayAttribute (grp.Attributes);\r
+                                       if (att != null) return att;\r
+                               }\r
                        }\r
+                       return null;\r
                }\r
 \r
                void ImportParticleComplexContent (XmlQualifiedName typeQName, ClassMap cmap, XmlSchemaParticle particle, CodeIdentifiers classIds, bool isMixed)\r
@@ -690,11 +801,10 @@ namespace System.Xml.Serialization {
 \r
                void ImportComplexContent (XmlQualifiedName typeQName, XmlTypeMapping map, XmlSchemaComplexContent content, CodeIdentifiers classIds, bool isMixed)\r
                {\r
-                       XmlSchemaComplexContentExtension ext = content.Content as XmlSchemaComplexContentExtension;\r
-\r
                        ClassMap cmap = (ClassMap)map.ObjectMap;\r
                        XmlQualifiedName qname;\r
 \r
+                       XmlSchemaComplexContentExtension ext = content.Content as XmlSchemaComplexContentExtension;\r
                        if (ext != null) qname = ext.BaseTypeName;\r
                        else qname = ((XmlSchemaComplexContentRestriction)content.Content).BaseTypeName;\r
                        \r
@@ -715,7 +825,8 @@ namespace System.Xml.Serialization {
 \r
                        if (ext != null) {\r
                                // Add the members of this map\r
-                               ImportParticleComplexContent (typeQName, cmap, ext.Particle, classIds, isMixed);\r
+                               if (ext.Particle != null)\r
+                                       ImportParticleComplexContent (typeQName, cmap, ext.Particle, classIds, isMixed);\r
 \r
                                ImportAttributes (typeQName, cmap, ext.Attributes, ext.AnyAttribute, classIds);\r
                        }\r
@@ -723,6 +834,24 @@ namespace System.Xml.Serialization {
                                if (isMixed) ImportParticleComplexContent (typeQName, cmap, null, classIds, true);\r
                        }\r
                }\r
+               \r
+               void ImportExtensionTypes (XmlQualifiedName qname)\r
+               {\r
+                       foreach (XmlSchema schema in schemas) {\r
+                               foreach (XmlSchemaObject sob in schema.Items) \r
+                               {\r
+                                       XmlSchemaComplexType sct = sob as XmlSchemaComplexType;\r
+                                       if (sct != null && sct.ContentModel is XmlSchemaComplexContent) {\r
+                                               XmlQualifiedName exqname;\r
+                                               XmlSchemaComplexContentExtension ext = sct.ContentModel.Content as XmlSchemaComplexContentExtension;\r
+                                               if (ext != null) exqname = ext.BaseTypeName;\r
+                                               else exqname = ((XmlSchemaComplexContentRestriction)sct.ContentModel.Content).BaseTypeName;\r
+                                               if (exqname == qname)\r
+                                                       ImportType (new XmlQualifiedName (sct.Name, schema.TargetNamespace), sct, null);\r
+                                       }\r
+                               }\r
+                       }                                       \r
+               }\r
 \r
                XmlTypeMapping ImportClassSimpleType (XmlQualifiedName typeQName, XmlSchemaSimpleType stype, XmlQualifiedName root)\r
                {\r
@@ -786,8 +915,19 @@ namespace System.Xml.Serialization {
 \r
                bool CanBeArray (XmlQualifiedName typeQName, XmlSchemaComplexType stype)\r
                {\r
-                       if (stype.Attributes.Count > 0 || stype.AnyAttribute != null) return false;\r
-                       else return !stype.IsMixed && CanBeArray (typeQName, stype.Particle, false);\r
+                       if (encodedFormat)\r
+                       {\r
+                               XmlSchemaComplexContent content = stype.ContentModel as XmlSchemaComplexContent;\r
+                               if (content == null) return false;\r
+                               XmlSchemaComplexContentRestriction rest = content.Content as XmlSchemaComplexContentRestriction;\r
+                               if (rest == null) return false;\r
+                               return rest.BaseTypeName == arrayType;\r
+                       }\r
+                       else\r
+                       {\r
+                               if (stype.Attributes.Count > 0 || stype.AnyAttribute != null) return false;\r
+                               else return !stype.IsMixed && CanBeArray (typeQName, stype.Particle, false);\r
+                       }\r
                }\r
 \r
                bool CanBeArray (XmlQualifiedName typeQName, XmlSchemaParticle particle, bool multiValue)\r
@@ -937,7 +1077,10 @@ namespace System.Xml.Serialization {
 \r
                XmlTypeMapping CreateArrayTypeMapping (XmlQualifiedName typeQName, TypeData arrayTypeData)\r
                {\r
-                       XmlTypeMapping map = new XmlTypeMapping (arrayTypeData.XmlType, typeQName.Namespace, arrayTypeData, arrayTypeData.XmlType, typeQName.Namespace);\r
+                       XmlTypeMapping map;\r
+                       if (encodedFormat) map = new XmlTypeMapping ("Array", XmlSerializer.EncodingNamespace, arrayTypeData, "Array", XmlSerializer.EncodingNamespace);\r
+                       else map = new XmlTypeMapping (arrayTypeData.XmlType, typeQName.Namespace, arrayTypeData, arrayTypeData.XmlType, typeQName.Namespace);\r
+                       \r
                        mappedTypes [typeQName] = map;\r
                        dataMappedTypes [arrayTypeData] = map;\r
 \r
index 1018c48b3bc8fb385c9c1bf01c8daadf21877133..800fd1eddb9e500adb2f44f2338340a3cc329340 100644 (file)
@@ -51,15 +51,15 @@ namespace System.Xml.Serialization {
 
                internal void Initialize (XmlReader reader, XmlSerializer eventSource)
                {
-                       w3SchemaNS = reader.NameTable.Add ("http://www.w3.org/2001/XMLSchema");
+                       w3SchemaNS = reader.NameTable.Add (XmlSchema.Namespace);
                        w3SchemaNS2000 = reader.NameTable.Add ("http://www.w3.org/2000/10/XMLSchema");
                        w3SchemaNS1999 = reader.NameTable.Add ("http://www.w3.org/1999/XMLSchema");
-                       w3InstanceNS = reader.NameTable.Add ("http://www.w3.org/2001/XMLSchema-instance");
+                       w3InstanceNS = reader.NameTable.Add (XmlSchema.InstanceNamespace);
                        w3InstanceNS2000 = reader.NameTable.Add ("http://www.w3.org/2000/10/XMLSchema-instance");
                        w3InstanceNS1999 = reader.NameTable.Add ("http://www.w3.org/1999/XMLSchema-instance");
-                       soapNS = reader.NameTable.Add ("http://schemas.xmlsoap.org/soap/encoding/");
+                       soapNS = reader.NameTable.Add (XmlSerializer.EncodingNamespace);
                        schema = reader.NameTable.Add ("schema");
-                       wsdlNS = reader.NameTable.Add ("http://schemas.xmlsoap.org/wsdl/");
+                       wsdlNS = reader.NameTable.Add (XmlSerializer.WsdlNamespace);
                        wsdlArrayType = reader.NameTable.Add ("arrayType");
                        nullX = reader.NameTable.Add ("null");
                        nil = reader.NameTable.Add ("nil");
@@ -68,7 +68,7 @@ namespace System.Xml.Serialization {
                        anyType = reader.NameTable.Add ("anyType");
                        this.reader = reader;
                        this.eventSource = eventSource;
-                       arrayQName = new XmlQualifiedName ("Array", soapNS);
+                       arrayQName = new XmlQualifiedName ("Array", XmlSerializer.EncodingNamespace);
                        InitIDs ();
                }
                        
@@ -300,10 +300,15 @@ namespace System.Xml.Serialization {
                        return name.StartsWith ("xmlns:");
                }
 
-               [MonoTODO ("Implement")]
                protected void ParseWsdlArrayType (XmlAttribute attr)
                {
-                       throw new NotImplementedException ();
+                       if (attr.NamespaceURI == XmlSerializer.WsdlNamespace && attr.LocalName == "arrayType")
+                       {
+                               string ns = "", type, dimensions;
+                               TypeTranslator.ParseArrayType (attr.Value, out type, out ns, out dimensions);
+                               if (ns != "") ns = Reader.LookupNamespace (ns) + ":";
+                               attr.Value = ns + type + dimensions;
+                       }
                }
 
                protected XmlQualifiedName ReadElementQualifiedName ()
@@ -440,7 +445,7 @@ namespace System.Xml.Serialization {
 
                bool ReadList (out object resultList)
                {
-                       string arrayType = Reader.GetAttribute ("arrayType", soapNS);
+                       string arrayType = Reader.GetAttribute ("arrayType", XmlSerializer.WsdlNamespace);
                        XmlQualifiedName qn = ToXmlQualifiedName (arrayType);
                        int i = qn.Name.LastIndexOf ('[');
                        string dim = qn.Name.Substring (i);
index a821f14f18698c53e02265274d9eb7c7d4a1c0f4..f432e460eaf17f383e5bd8b46a8ce0bb0bba3b8d 100644 (file)
@@ -209,7 +209,9 @@ namespace System.Xml.Serialization
                                        }       
                                        else if (anyAttrMember != null) 
                                        {
-                                               AddListValue (anyAttrMember.TypeData, ref anyAttributeArray, anyAttributeIndex++, Document.ReadNode(Reader), true);
+                                               XmlAttribute attr = (XmlAttribute) Document.ReadNode(Reader);
+                                               ParseWsdlArrayType (attr);
+                                               AddListValue (anyAttrMember.TypeData, ref anyAttributeArray, anyAttributeIndex++, attr, true);
                                        }
                                        else
                                                ProcessUnknownAttribute(ob);
@@ -230,7 +232,7 @@ namespace System.Xml.Serialization
 
                        // Reads elements
 
-                       bool[] readFlag = new bool[map.ElementMembers.Count];
+                       bool[] readFlag = new bool[(map.ElementMembers != null) ? map.ElementMembers.Count : 0];
 
                        Reader.MoveToContent();
 
index 2abbfaf1c9036362a2b62b62a44e8fd0854a97d9..b1af3e23f89675d402963eb212f02111525b8fdb 100644 (file)
@@ -735,12 +735,25 @@ namespace System.Xml.Serialization {
                        WriteXmlAttribute (node, null);
                }
 
-               [MonoTODO ("Implement")]
                protected void WriteXmlAttribute (XmlNode node, object container)
                {
-                       if (!(node is XmlAttribute))
+                       XmlAttribute attr = node as XmlAttribute;
+                       if (attr == null)
                                throw new InvalidOperationException ("The node must be either type XmlAttribute or a derived type.");
-                       throw new NotImplementedException ();
+                       
+                       if (attr.NamespaceURI == XmlSerializer.WsdlNamespace)
+                       {
+                               // The wsdl arrayType attribute needs special handling
+                               if (attr.LocalName == "arrayType") {
+                                       string ns, type, dimensions;
+                                       TypeTranslator.ParseArrayType (attr.Value, out type, out ns, out dimensions);
+                                       string value = GetQualifiedName (type + dimensions, ns);
+                                       WriteAttribute (attr.Prefix, attr.LocalName, attr.NamespaceURI, value);
+                                       return;
+                               }
+                       }
+                       
+                       WriteAttribute (attr.Prefix, attr.LocalName, attr.NamespaceURI, attr.Value);
                }
 
                protected void WriteXsiType (string name, string ns)
index 40bba7ae72adcceee8bf9eaf10cd5a3ff0953a07..2fb2c1e2a60b5c6007862aa42fa0b8cd6f8782b4 100644 (file)
@@ -194,7 +194,7 @@ namespace System.Xml.Serialization
                                if (extraAtts != null) 
                                {
                                        foreach (XmlAttribute attr in extraAtts)
-                                               WriteAttribute (attr.Prefix, attr.LocalName, attr.NamespaceURI, attr.Value);
+                                               WriteXmlAttribute (attr, ob);
                                }
                        }
                }
@@ -358,7 +358,7 @@ namespace System.Xml.Serialization
                                int itemCount = GetListCount (typeMap.TypeData, ob);
                                ((ListMap) typeMap.ObjectMap).GetArrayType (itemCount, out n, out ns);
                                string arrayType = (ns != string.Empty) ? FromXmlQualifiedName (new XmlQualifiedName(n,ns)) : n;
-                               WriteAttribute ("arrayType", SoapReflectionImporter.EncodingNamespace, arrayType);
+                               WriteAttribute ("arrayType", XmlSerializer.WsdlNamespace, arrayType);
                        }
                        WriteListContent (typeMap.TypeData, (ListMap) typeMap.ObjectMap, ob, null);
                }
index 1e23560c14d0fe41aed02ef6feaa121001edd040..2f16f9a1e222ee7064f011326fa30b27e6d7be51 100644 (file)
@@ -20,6 +20,8 @@ namespace System.Xml.Serialization
 
        public class XmlSerializer
        {
+               internal const string WsdlNamespace = "http://schemas.xmlsoap.org/wsdl/";
+               internal const string EncodingNamespace = "http://schemas.xmlsoap.org/soap/encoding/";
 
 #region Fields
 
index 2f082fad66683ae68a1e2a98b5bf8a6cda6cd5f1..b48c1e2187aad0720f855fad88b9df74f2301051 100644 (file)
@@ -359,6 +359,13 @@ namespace System.Xml.Serialization
                                if (elem.ElementName == elementName && elem.Namespace == ns) return elem;\r
                        return null;\r
                }\r
+               \r
+               public string GetSchemaArrayName ()\r
+               {\r
+                       XmlTypeMapElementInfo einfo = (XmlTypeMapElementInfo) _itemInfo[0];\r
+                       if (einfo.MappedType != null) return TypeTranslator.GetArrayName (einfo.MappedType.XmlType);\r
+                       else return TypeTranslator.GetArrayName (einfo.TypeData.XmlType);\r
+               }\r
 \r
                public void GetArrayType (int itemCount, out string localName, out string ns)\r
                {\r