Browse Source

* SoapCodeExporter.cs: Initial implementation of AddMappingMetadata().
* SoapReflectionImporter.cs, XmlReflectionImporter.cs, XmlSchemaImporter.cs:
in ImportMembersMapping, set pass the namespace to each XmlMemberMapping.
* SoapSchemaExporter.cs: Some fixes in ExportMembersMapping.
* XmlMemberMapping.cs: Fixed constructor. Now it takes the default namespace
and whether it uses encoded or literal format.
* XmlSchemaExporter.cs: Little fixes.

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

Lluis Sanchez 22 years ago
parent
commit
2a02ffdb25

+ 10 - 0
mcs/class/System.XML/System.Xml.Serialization/ChangeLog

@@ -1,3 +1,13 @@
+2003-10-13  Lluis Sanchez Gual <[email protected]>
+
+	* SoapCodeExporter.cs: Initial implementation of AddMappingMetadata().
+	* SoapReflectionImporter.cs, XmlReflectionImporter.cs, XmlSchemaImporter.cs: 
+	  in ImportMembersMapping, set pass the namespace to each XmlMemberMapping.
+	* SoapSchemaExporter.cs: Some fixes in ExportMembersMapping.
+	* XmlMemberMapping.cs: Fixed constructor. Now it takes the default namespace
+	  and whether it uses encoded or literal format.
+	* XmlSchemaExporter.cs: Little fixes.
+
 2003-10-10  Lluis Sanchez Gual <[email protected]>
 
 	* XmlSerializationReader.cs. Fixed bug #49510. An array element doesn't

+ 12 - 5
mcs/class/System.XML/System.Xml.Serialization/SoapCodeExporter.cs

@@ -46,16 +46,23 @@ namespace System.Xml.Serialization {
 
 		#region Methods
 
-		[MonoTODO]
 		public void AddMappingMetadata (CodeAttributeDeclarationCollection metadata, XmlMemberMapping member)
 		{
-			throw new NotImplementedException ();
+			AddMappingMetadata (metadata, member, false);
 		}
 
-		[MonoTODO]
 		public void AddMappingMetadata (CodeAttributeDeclarationCollection metadata, XmlMemberMapping member, bool forceUseMemberName)
 		{
-			throw new NotImplementedException ();
+			TypeData memType = member.TypeMapMember.TypeData;
+			
+			CodeAttributeDeclaration att = new CodeAttributeDeclaration ("System.Xml.Serialization.SoapElement");
+			if (forceUseMemberName || (member.ElementName != member.MemberName))
+				att.Arguments.Add (new CodeAttributeArgument ("ElementName", new CodePrimitiveExpression(member.ElementName)));
+			if (!TypeTranslator.IsDefaultPrimitiveTpeData (memType))
+				att.Arguments.Add (new CodeAttributeArgument ("DataType", new CodePrimitiveExpression(member.TypeName)));
+				
+			if (att.Arguments.Count > 0) 
+				metadata.Add (att);
 		}
 
 		[MonoTODO]
@@ -72,4 +79,4 @@ namespace System.Xml.Serialization {
 
 		#endregion // Methods
 	}
-}
+}

+ 1 - 1
mcs/class/System.XML/System.Xml.Serialization/SoapReflectionImporter.cs

@@ -64,7 +64,7 @@ namespace System.Xml.Serialization {
 			for (int n=0; n<members.Length; n++)
 			{
 				XmlTypeMapMember mapMem = CreateMapMember (members[n], ns);
-				mapping[n] = new XmlMemberMapping (members[n].MemberName, mapMem);
+				mapping[n] = new XmlMemberMapping (members[n].MemberName, ns, mapMem, true);
 			}
 			XmlMembersMapping mps = new XmlMembersMapping (elementName, ns, hasWrapperElement, mapping);
 			mps.RelatedMaps = relatedMaps;

+ 2 - 3
mcs/class/System.XML/System.Xml.Serialization/SoapSchemaExporter.cs

@@ -23,14 +23,13 @@ namespace System.Xml.Serialization
 
 		public void ExportMembersMapping (XmlMembersMapping xmlMembersMapping)
 		{
-			_exporter.ExportMembersMapping (xmlMembersMapping);
+			_exporter.ExportMembersMapping (xmlMembersMapping, false);
 		}
 
-		[MonoTODO]
 		public void ExportMembersMapping (XmlMembersMapping xmlMembersMapping,
 						  bool exportEnclosingType)
 		{
-			throw new NotImplementedException ();
+			_exporter.ExportMembersMapping (xmlMembersMapping, exportEnclosingType);
 		}
 
 		public void ExportTypeMapping (XmlTypeMapping xmlTypeMapping)

+ 13 - 4
mcs/class/System.XML/System.Xml.Serialization/XmlMemberMapping.cs

@@ -18,7 +18,7 @@ namespace System.Xml.Serialization
 		string _namespace;
 		string _typeNamespace;
 
-		internal XmlMemberMapping (string memberName, XmlTypeMapMember mapMem)
+		internal XmlMemberMapping (string memberName, string defaultNamespace, XmlTypeMapMember mapMem, bool encodedFormat)
 		{
 			_mapMember = mapMem;
 			_memberName = memberName;
@@ -27,9 +27,18 @@ namespace System.Xml.Serialization
 			{
 				XmlTypeMapElementInfo info = (XmlTypeMapElementInfo) ((XmlTypeMapMemberElement)mapMem).ElementInfo[0];
 				_elementName = info.ElementName;
-				_namespace = info.Namespace;
-				if (info.MappedType != null) _typeNamespace = info.MappedType.Namespace;
-				else _typeNamespace = "";
+				if (encodedFormat)
+				{
+					_namespace = defaultNamespace;
+					if (info.MappedType != null) _typeNamespace = "";
+					else _typeNamespace = info.DataTypeNamespace;
+				}
+				else
+				{
+					_namespace = info.Namespace;
+					if (info.MappedType != null) _typeNamespace = info.MappedType.Namespace;
+					else _typeNamespace = "";
+				}
 			}
 			else
 			{

+ 1 - 1
mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs

@@ -77,7 +77,7 @@ namespace System.Xml.Serialization {
 			for (int n=0; n<members.Length; n++)
 			{
 				XmlTypeMapMember mapMem = CreateMapMember (members[n], ns);
-				mapping[n] = new XmlMemberMapping (members[n].MemberName, mapMem);
+				mapping[n] = new XmlMemberMapping (members[n].MemberName, ns, mapMem, false);
 			}
 			XmlMembersMapping mps = new XmlMembersMapping (elementName, ns, hasWrapperElement, mapping);
 			mps.RelatedMaps = relatedMaps;

+ 17 - 2
mcs/class/System.XML/System.Xml.Serialization/XmlSchemaExporter.cs

@@ -49,11 +49,16 @@ namespace System.Xml.Serialization {
 		}
 
 		public void ExportMembersMapping (XmlMembersMapping xmlMembersMapping)
+		{
+			ExportMembersMapping (xmlMembersMapping, true);
+		}
+		
+		internal void ExportMembersMapping (XmlMembersMapping xmlMembersMapping, bool exportEnclosingType)
 		{
 			XmlSchema schema = GetSchema (xmlMembersMapping.Namespace);
 			ClassMap cmap = (ClassMap) xmlMembersMapping.ObjectMap;
 
-			if (xmlMembersMapping.HasWrapperElement)
+			if (xmlMembersMapping.HasWrapperElement && exportEnclosingType)
 			{
 				XmlSchemaComplexType stype = new XmlSchemaComplexType ();
 	
@@ -98,6 +103,10 @@ namespace System.Xml.Serialization {
 					}
 				}
 			}
+			
+			if (encodedFormat) 
+				ImportNamespace (schema, XmlSerializer.EncodingNamespace);
+				
 			CompileSchemas ();
 		}
 
@@ -113,7 +122,11 @@ namespace System.Xml.Serialization {
 			if (IsElementExported (xmlTypeMapping)) return;
 			
 			if (encodedFormat)
+			{
 				ExportClassSchema (xmlTypeMapping);
+				XmlSchema schema = GetSchema (xmlTypeMapping.XmlTypeNamespace);
+				ImportNamespace (schema, XmlSerializer.EncodingNamespace);
+			}
 			else
 			{
 				XmlSchema schema = GetSchema (xmlTypeMapping.Namespace);
@@ -126,6 +139,7 @@ namespace System.Xml.Serialization {
 				AddSchemaElement (schema.Items, schema, einfo, false);
 				SetElementExported (xmlTypeMapping);
 			}
+			
 			CompileSchemas ();
 		}
 
@@ -503,7 +517,8 @@ namespace System.Xml.Serialization {
 				XmlAttribute arrayType = Document.CreateAttribute ("arrayType", XmlSerializer.WsdlNamespace);
 				arrayType.Value = ns + (ns != "" ? ":" : "") + name;
 				at.UnhandledAttributes = new XmlAttribute [] { arrayType };
-				
+				ImportNamespace (schema, XmlSerializer.WsdlNamespace);
+			
 				XmlTypeMapElementInfo einfo = (XmlTypeMapElementInfo) lmap.ItemInfo[0];
 				if (einfo.MappedType != null)
 				{

+ 2 - 2
mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs

@@ -196,7 +196,7 @@ namespace System.Xml.Serialization {
 			int n = 0;
 			XmlMemberMapping[] mapping = new XmlMemberMapping [cmap.AllMembers.Count];
 			foreach (XmlTypeMapMember mapMem in cmap.AllMembers)
-				mapping[n++] = new XmlMemberMapping (mapMem.Name, mapMem);
+				mapping[n++] = new XmlMemberMapping (mapMem.Name, refer.Namespace, mapMem, encodedFormat);
 				
 			return mapping;
 		}
@@ -207,7 +207,7 @@ namespace System.Xml.Serialization {
 			mapMem.Name = name;
 			mapMem.TypeData = type;
 			mapMem.ElementInfo.Add (CreateElementInfo (ns, mapMem, name, type, true));
-			return new XmlMemberMapping (name, mapMem);
+			return new XmlMemberMapping (name, ns, mapMem, encodedFormat);
 		}
 		
 		[MonoTODO]