Author: lluis
Date: 2005-04-14 10:22:55 -0400 (Thu, 14 Apr 2005)
New Revision: 43003
Modified:
trunk/mcs/class/System.XML/System.Xml.Serialization/ChangeLog
trunk/mcs/class/System.XML/System.Xml.Serialization/SoapReflectionImporter.cs
trunk/mcs/class/System.XML/System.Xml.Serialization/TypeTranslator.cs
trunk/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs
Log:
2005-04-14 Lluis Sanchez Gual <[EMAIL PROTECTED]>
* XmlReflectionImporter.cs:
* SoapReflectionImporter.cs:
* TypeTranslator.cs: Encode local names withXmlConvert.EncodeLocalName
where needed. Based on a patch by Konstantin Triger.
Modified: trunk/mcs/class/System.XML/System.Xml.Serialization/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/System.Xml.Serialization/ChangeLog
2005-04-14 13:28:29 UTC (rev 43002)
+++ trunk/mcs/class/System.XML/System.Xml.Serialization/ChangeLog
2005-04-14 14:22:55 UTC (rev 43003)
@@ -1,3 +1,10 @@
+2005-04-14 Lluis Sanchez Gual <[EMAIL PROTECTED]>
+
+ * XmlReflectionImporter.cs:
+ * SoapReflectionImporter.cs:
+ * TypeTranslator.cs: Encode local names withXmlConvert.EncodeLocalName
+ where needed. Based on a patch by Konstantin Triger.
+
2005-04-12 Lluis Sanchez Gual <[EMAIL PROTECTED]>
* XmlTypeMapping.cs: Added new XmlSerializableMapping class.
@@ -6,7 +13,7 @@
check for default namespace, since it may be included from a non
default namespace.
* XmlReflectionImporter.cs: Create a special map for IXmlSerializable
- types. All this based on a patch by Andrew Skiba.
+ types. All this based on a patch by Konstantin Triger.
* SerializationCodeGenerator.cs:
* XmlMapping.cs:
Modified:
trunk/mcs/class/System.XML/System.Xml.Serialization/SoapReflectionImporter.cs
===================================================================
---
trunk/mcs/class/System.XML/System.Xml.Serialization/SoapReflectionImporter.cs
2005-04-14 13:28:29 UTC (rev 43002)
+++
trunk/mcs/class/System.XML/System.Xml.Serialization/SoapReflectionImporter.cs
2005-04-14 14:22:55 UTC (rev 43003)
@@ -80,12 +80,13 @@
}
public XmlMembersMapping ImportMembersMapping (string
elementName, string ns, XmlReflectionMember[] members, bool hasWrapperElement,
bool writeAccessors, bool validate)
- {
+ {
+ elementName = XmlConvert.EncodeLocalName (elementName);
XmlMemberMapping[] mapping = new
XmlMemberMapping[members.Length];
for (int n=0; n<members.Length; n++)
{
XmlTypeMapMember mapMem = CreateMapMember
(members[n], ns);
- mapping[n] = new XmlMemberMapping
(members[n].MemberName, ns, mapMem, true);
+ mapping[n] = new XmlMemberMapping
(XmlConvert.EncodeLocalName (members[n].MemberName), ns, mapMem, true);
}
XmlMembersMapping mps = new XmlMembersMapping
(elementName, ns, hasWrapperElement, writeAccessors, mapping);
mps.RelatedMaps = relatedMaps;
@@ -155,7 +156,7 @@
membersNamespace =
atts.SoapType.Namespace;
if (atts.SoapType.TypeName != null &&
atts.SoapType.TypeName != string.Empty)
- defaultXmlType = atts.SoapType.TypeName;
+ defaultXmlType =
XmlConvert.EncodeLocalName (atts.SoapType.TypeName);
includeInSchema = atts.SoapType.IncludeInSchema;
}
@@ -348,7 +349,7 @@
string xmlName = names[n];
object[] atts = mem[0].GetCustomAttributes
(typeof(SoapEnumAttribute), false);
if (atts.Length > 0) xmlName =
((SoapEnumAttribute)atts[0]).Name;
- members[n] = new EnumMap.EnumMapMember
(xmlName, names[n]);
+ members[n] = new EnumMap.EnumMapMember
(XmlConvert.EncodeLocalName (xmlName), names[n]);
}
bool isFlags = type.GetCustomAttributes
(typeof(FlagsAttribute),false).Length > 0;
@@ -401,9 +402,9 @@
XmlTypeMapMemberAttribute mapAttribute = new
XmlTypeMapMemberAttribute ();
if (atts.SoapAttribute.AttributeName == null)
- mapAttribute.AttributeName =
rmember.MemberName;
+ mapAttribute.AttributeName =
XmlConvert.EncodeLocalName (rmember.MemberName);
else
- mapAttribute.AttributeName =
atts.SoapAttribute.AttributeName;
+ mapAttribute.AttributeName =
XmlConvert.EncodeLocalName (atts.SoapAttribute.AttributeName);
mapAttribute.Namespace =
(atts.SoapAttribute.Namespace != null) ? atts.SoapAttribute.Namespace : "";
if (typeData.IsComplexType)
@@ -424,7 +425,7 @@
XmlTypeMapElementInfoList infoList = new
XmlTypeMapElementInfoList();
XmlTypeMapElementInfo elem = new
XmlTypeMapElementInfo (mapMember, typeData);
- elem.ElementName = (atts.SoapElement != null &&
atts.SoapElement.ElementName != null) ? atts.SoapElement.ElementName :
rmember.MemberName;
+ elem.ElementName = XmlConvert.EncodeLocalName
((atts.SoapElement != null && atts.SoapElement.ElementName != null) ?
atts.SoapElement.ElementName : rmember.MemberName);
elem.Namespace = string.Empty;
elem.IsNullable = (atts.SoapElement != null) ?
atts.SoapElement.IsNullable : false;
if (typeData.IsComplexType)
Modified: trunk/mcs/class/System.XML/System.Xml.Serialization/TypeTranslator.cs
===================================================================
--- trunk/mcs/class/System.XML/System.Xml.Serialization/TypeTranslator.cs
2005-04-14 13:28:29 UTC (rev 43002)
+++ trunk/mcs/class/System.XML/System.Xml.Serialization/TypeTranslator.cs
2005-04-14 14:22:55 UTC (rev 43003)
@@ -127,7 +127,7 @@
name = GetArrayName (sufix);
}
else
- name = type.Name;
+ name = XmlConvert.EncodeLocalName (type.Name);
typeData = new TypeData (type, name, false);
nameCache[type] = typeData;
Modified:
trunk/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs
===================================================================
---
trunk/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs
2005-04-14 13:28:29 UTC (rev 43002)
+++
trunk/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs
2005-04-14 14:22:55 UTC (rev 43003)
@@ -113,6 +113,7 @@
XmlTypeMapMember mapMem = CreateMapMember
(null, members[n], ns);
mapping[n] = new XmlMemberMapping
(members[n].MemberName, ns, mapMem, false);
}
+ elementName = XmlConvert.EncodeLocalName (elementName);
XmlMembersMapping mps = new XmlMembersMapping
(elementName, ns, hasWrapperElement, false, mapping);
mps.RelatedMaps = relatedMaps;
mps.Format = SerializationFormat.Literal;
@@ -224,7 +225,7 @@
typeNamespace = atts.XmlType.Namespace;
if (atts.XmlType.TypeName != null &&
atts.XmlType.TypeName != string.Empty)
- defaultXmlType = atts.XmlType.TypeName;
+ defaultXmlType =
XmlConvert.EncodeLocalName (atts.XmlType.TypeName);
includeInSchema = atts.XmlType.IncludeInSchema;
}
@@ -234,7 +235,7 @@
if (root != null)
{
if (root.ElementName != null &&
root.ElementName != String.Empty)
- elementName = root.ElementName;
+ elementName =
XmlConvert.EncodeLocalName(root.ElementName);
if (root.Namespace != null && root.Namespace !=
String.Empty)
rootNamespace = root.Namespace;
nullable = root.IsNullable;
@@ -421,7 +422,7 @@
else if (elem.TypeData.IsComplexType)
elem.MappedType = ImportTypeMapping
(elemType, null, elem.Namespace);
- if (att.ElementName != null) elem.ElementName =
att.ElementName;
+ if (att.ElementName != null) elem.ElementName =
XmlConvert.EncodeLocalName(att.ElementName);
else if (elem.MappedType != null)
elem.ElementName = elem.MappedType.ElementName;
else elem.ElementName =
TypeTranslator.GetTypeData(elemType).XmlType;
@@ -546,7 +547,7 @@
atts = mem[0].GetCustomAttributes
(typeof(XmlEnumAttribute), false);
if (atts.Length > 0) xmlName =
((XmlEnumAttribute)atts[0]).Name;
if (xmlName == null) xmlName = name;
- members.Add (new EnumMap.EnumMapMember
(xmlName, name));
+ members.Add (new EnumMap.EnumMapMember
(XmlConvert.EncodeLocalName (xmlName), name));
}
bool isFlags = type.GetCustomAttributes
(typeof(FlagsAttribute),false).Length > 0;
@@ -718,6 +719,8 @@
else
mapAttribute.AttributeName =
atts.XmlAttribute.AttributeName;
+ mapAttribute.AttributeName =
XmlConvert.EncodeLocalName (mapAttribute.AttributeName);
+
if (typeData.IsComplexType)
mapAttribute.MappedType =
ImportTypeMapping (typeData.Type, null, mapAttribute.Namespace);
@@ -754,7 +757,7 @@
// TODO: check that it does not have
XmlArrayAttribute
XmlTypeMapMemberFlatList member = new
XmlTypeMapMemberFlatList ();
member.ListMap = new ListMap ();
- member.ListMap.ItemInfo =
ImportElementInfo (declaringType, rmember.MemberName, defaultNamespace,
typeData.ListItemType, member, atts);
+ member.ListMap.ItemInfo =
ImportElementInfo (declaringType, XmlConvert.EncodeLocalName
(rmember.MemberName), defaultNamespace, typeData.ListItemType, member, atts);
member.ElementInfo =
member.ListMap.ItemInfo;
mapMember = member;
}
@@ -767,7 +770,7 @@
// Creates an ElementInfo that
identifies the array instance.
member.ElementInfo = new
XmlTypeMapElementInfoList();
XmlTypeMapElementInfo elem = new
XmlTypeMapElementInfo (member, typeData);
- elem.ElementName = (atts.XmlArray !=
null && atts.XmlArray.ElementName != null) ? atts.XmlArray.ElementName :
rmember.MemberName;
+ elem.ElementName =
XmlConvert.EncodeLocalName((atts.XmlArray != null && atts.XmlArray.ElementName
!= null) ? atts.XmlArray.ElementName : rmember.MemberName);
elem.Namespace = (atts.XmlArray != null
&& atts.XmlArray.Namespace != null) ? atts.XmlArray.Namespace :
defaultNamespace;
elem.MappedType = ImportListMapping
(rmember.MemberType, null, elem.Namespace, atts, 0);
elem.IsNullable = (atts.XmlArray !=
null) ? atts.XmlArray.IsNullable : false;
@@ -782,7 +785,7 @@
// An element
XmlTypeMapMemberElement member = new
XmlTypeMapMemberElement ();
- member.ElementInfo = ImportElementInfo
(declaringType, rmember.MemberName, defaultNamespace, rmember.MemberType,
member, atts);
+ member.ElementInfo = ImportElementInfo
(declaringType, XmlConvert.EncodeLocalName(rmember.MemberName),
defaultNamespace, rmember.MemberType, member, atts);
mapMember = member;
}
@@ -832,7 +835,6 @@
{
Type elemType = (att.Type != null) ? att.Type :
defaultType;
XmlTypeMapElementInfo elem = new
XmlTypeMapElementInfo (member, TypeTranslator.GetTypeData(elemType,
att.DataType));
- elem.ElementName = (att.ElementName != null) ?
att.ElementName : defaultName;
elem.Namespace = (att.Namespace != null) ?
att.Namespace : defaultNamespace;
elem.Form = att.Form;
elem.IsNullable = att.IsNullable;
@@ -847,7 +849,7 @@
}
if (att.ElementName != null)
- elem.ElementName = att.ElementName;
+ elem.ElementName =
XmlConvert.EncodeLocalName(att.ElementName);
else if (multiType) {
if (elem.MappedType != null)
elem.ElementName = elem.MappedType.ElementName;
else elem.ElementName =
TypeTranslator.GetTypeData(elemType).XmlType;
@@ -877,7 +879,7 @@
XmlTypeMapElementInfo elem = new
XmlTypeMapElementInfo (member, TypeTranslator.GetTypeData(typeof(XmlElement)));
if (att.Name != null && att.Name !=
string.Empty)
{
- elem.ElementName = att.Name;
+ elem.ElementName =
XmlConvert.EncodeLocalName(att.Name);
elem.Namespace = (att.Namespace !=
null) ? att.Namespace : "";
}
else
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches