parameter of type enum.
* XmlAttributeAttribute.cs: little fix.
* XmlCodeExporter.cs: Support XmlAnyAttribute when generating attributes
for method parameters.
* XmlMemberMapping.cs: Improved support for members of type "any".
* XmlReflectionImporter.cs: Improved assignment of the attribute form.
If the namespace is explicitly specified, then the form should be
qualified. Also fixed issues with the namespace assigned to attributes.
This should fix bug #53384.
* XmlSchemaExporter.cs: ExportMembersMapping(): improved support for
methods that return values of type "any". Changed the methods
AddSchemaArrayElement and AddSchemaElement, so instead of adding the
element, return it, and the caller must add it to the collection.
Other fixes in attribute generation.
* XmlSchemaImporter.cs: ImportAnyType(): if a type name is provided,
generate the AnyType mapping from the type described in the schema.
Small fixes regarding IsMixed property of complex types (it means that
the type can contain text, so the XmlTextAttribute must be generated).
* XmlSerializationReaderInterpreter.cs: Reading of members by-order must
be only used in the bare+encoded format.
svn path=/trunk/mcs/; revision=22533
+2004-01-27 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * MapCodeGenerator.cs: Added helper method for generating an attribute
+ parameter of type enum.
+ * XmlAttributeAttribute.cs: little fix.
+ * XmlCodeExporter.cs: Support XmlAnyAttribute when generating attributes
+ for method parameters.
+ * XmlMemberMapping.cs: Improved support for members of type "any".
+ * XmlReflectionImporter.cs: Improved assignment of the attribute form.
+ If the namespace is explicitly specified, then the form should be
+ qualified. Also fixed issues with the namespace assigned to attributes.
+ This should fix bug #53384.
+ * XmlSchemaExporter.cs: ExportMembersMapping(): improved support for
+ methods that return values of type "any". Changed the methods
+ AddSchemaArrayElement and AddSchemaElement, so instead of adding the
+ element, return it, and the caller must add it to the collection.
+ Other fixes in attribute generation.
+ * XmlSchemaImporter.cs: ImportAnyType(): if a type name is provided,
+ generate the AnyType mapping from the type described in the schema.
+ Small fixes regarding IsMixed property of complex types (it means that
+ the type can contain text, so the XmlTextAttribute must be generated).
+ * XmlSerializationReaderInterpreter.cs: Reading of members by-order must
+ be only used in the bare+encoded format.
+
2004-01-24 Lluis Sanchez Gual <lluis@ximian.com>
* SoapReflectionImporter.cs: Types included with SoapInclude don't need
return new CodeAttributeArgument (name, new CodeTypeOfExpression(typeName));
}
+ public CodeAttributeArgument GetEnumArg (string name, string enumType, string enumValue)
+ {
+ return new CodeAttributeArgument (name, new CodeFieldReferenceExpression (new CodeTypeReferenceExpression(enumType), enumValue));
+ }
+
public static void AddComments (CodeTypeMember member, string comments)
{
if (comments == null || comments == "") member.Comments.Add (new CodeCommentStatement ("<remarks/>", true));
return form;
}\r
set {
- if(Namespace != null)
form = value;
}\r
}\r
CodeAttributeDeclaration att;\r
TypeData memType = member.TypeMapMember.TypeData;\r
\r
- if (memType.SchemaType == SchemaTypes.Array)\r
+ if (member.Any)\r
+ {\r
+ XmlTypeMapElementInfoList list = (XmlTypeMapElementInfoList)((XmlTypeMapMemberElement)member.TypeMapMember).ElementInfo;\r
+ foreach (XmlTypeMapElementInfo info in list)\r
+ {\r
+ if (info.IsTextElement)\r
+ metadata.Add (new CodeAttributeDeclaration ("System.Xml.Serialization.XmlText"));\r
+ else {\r
+ att = new CodeAttributeDeclaration ("System.Xml.Serialization.XmlAnyElement");\r
+ if (!info.IsUnnamedAnyElement) {\r
+ att.Arguments.Add (MapCodeGenerator.GetArg ("Name", info.ElementName));\r
+ if (info.Namespace != ns) att.Arguments.Add (MapCodeGenerator.GetArg ("Namespace", member.Namespace));\r
+ }\r
+ metadata.Add (att);\r
+ }\r
+ }\r
+ }\r
+ else if (memType.SchemaType == SchemaTypes.Array)\r
{\r
// Array parameter\r
att = new CodeAttributeDeclaration ("System.Xml.Serialization.XmlArray");\r
CodeAttributeDeclaration att = new CodeAttributeDeclaration ("System.Xml.Serialization.XmlAttribute");\r
if (attinfo.Name != attinfo.AttributeName) att.Arguments.Add (GetArg (attinfo.AttributeName));\r
if (attinfo.Namespace != defaultNamespace) att.Arguments.Add (GetArg ("Namespace", attinfo.Namespace));\r
- if (attinfo.Form != XmlSchemaForm.None) att.Arguments.Add (GetArg ("Form",attinfo.Form));\r
+ if (attinfo.Form != XmlSchemaForm.None) att.Arguments.Add (GetEnumArg ("Form","System.Xml.Schema.XmlSchemaForm",attinfo.Form.ToString()));\r
if (!TypeTranslator.IsDefaultPrimitiveTpeData(attinfo.TypeData)) att.Arguments.Add (GetArg ("DataType",attinfo.TypeData.XmlType));\r
AddCustomAttribute (codeField, att, true);\r
}\r
_mapMember = mapMem;
_memberName = memberName;
- if (mapMem is XmlTypeMapMemberElement)
+ if (mapMem is XmlTypeMapMemberAnyElement)
+ {
+ XmlTypeMapMemberAnyElement anyelem = (XmlTypeMapMemberAnyElement) mapMem;
+ XmlTypeMapElementInfo info = (XmlTypeMapElementInfo) anyelem.ElementInfo[anyelem.ElementInfo.Count-1];
+ _elementName = info.ElementName;
+ _namespace = info.Namespace;
+ if (info.MappedType != null) _typeNamespace = info.MappedType.Namespace;
+ else _typeNamespace = "";
+ }
+ else if (mapMem is XmlTypeMapMemberElement)
{
XmlTypeMapElementInfo info = (XmlTypeMapElementInfo) ((XmlTypeMapMemberElement)mapMem).ElementInfo[0];
_elementName = info.ElementName;
using System.Reflection;
using System.Collections;
+using System.Xml.Schema;
namespace System.Xml.Serialization {
public class XmlReflectionImporter {
(rmember.MemberType.FullName == "System.Xml.XmlElement"))
{
XmlTypeMapMemberAnyElement member = new XmlTypeMapMemberAnyElement();
- member.ElementInfo = ImportAnyElementInfo (defaultNamespace, rmember.MemberType, member, atts);
+ member.ElementInfo = ImportAnyElementInfo (defaultNamespace, rmember, member, atts);
mapMember = member;
}
else
else
mapAttribute.AttributeName = atts.XmlAttribute.AttributeName;
- mapAttribute.Form = atts.XmlAttribute.Form;
- mapAttribute.Namespace = (atts.XmlAttribute.Namespace != null) ? atts.XmlAttribute.Namespace : "";
if (typeData.IsComplexType)
mapAttribute.MappedType = ImportTypeMapping (typeData.Type, null, mapAttribute.Namespace);
-
+
+ if (atts.XmlAttribute.Namespace != null && atts.XmlAttribute.Namespace != defaultNamespace)
+ {
+ if (atts.XmlAttribute.Form == XmlSchemaForm.Unqualified)
+ throw new InvalidOperationException ("The Form property may not be 'Unqualified' when an explicit Namespace property is present");
+ mapAttribute.Form = XmlSchemaForm.Qualified;
+ mapAttribute.Namespace = atts.XmlAttribute.Namespace;
+ }
+ else
+ {
+ mapAttribute.Form = atts.XmlAttribute.Form;
+ if (atts.XmlAttribute.Form == XmlSchemaForm.Qualified)
+ mapAttribute.Namespace = defaultNamespace;
+ else
+ mapAttribute.Namespace = "";
+ }
+
typeData = TypeTranslator.GetTypeData(rmember.MemberType, atts.XmlAttribute.DataType);
mapMember = mapAttribute;
}
return list;
}
- XmlTypeMapElementInfoList ImportAnyElementInfo (string defaultNamespace, Type defaultType, XmlTypeMapMemberElement member, XmlAttributes atts)
+ XmlTypeMapElementInfoList ImportAnyElementInfo (string defaultNamespace, XmlReflectionMember rmember, XmlTypeMapMemberElement member, XmlAttributes atts)
{
XmlTypeMapElementInfoList list = new XmlTypeMapElementInfoList();
- ImportTextElementInfo (list, defaultType, member, atts);
+ ImportTextElementInfo (list, rmember.MemberType, member, atts);
foreach (XmlAnyElementAttribute att in atts.XmlAnyElements)
{
XmlTypeMapElementInfo elem = new XmlTypeMapElementInfo (member, TypeTranslator.GetTypeData(typeof(XmlElement)));
- if (att.Name != null && att.Name != string.Empty) elem.ElementName = att.Name;
- else elem.IsUnnamedAnyElement = true;
- elem.Namespace = (att.Namespace != null) ? att.Namespace : "";
+ if (att.Name != null && att.Name != string.Empty)
+ {
+ elem.ElementName = att.Name;
+ elem.Namespace = (att.Namespace != null) ? att.Namespace : "";
+ }
+ else
+ {
+ elem.IsUnnamedAnyElement = true;
+ elem.Namespace = defaultNamespace;
+ if (att.Namespace != null)
+ throw new InvalidOperationException ("The element " + rmember.MemberName + " has been attributed with an XmlAnyElementAttribute and a namespace '" + att.Namespace + "', but no name. When a namespace is supplied, a name is also required. Supply a name or remove the namespace.");
+ }
list.Add (elem);
}
return list;
internal void ExportMembersMapping (XmlMembersMapping xmlMembersMapping, bool exportEnclosingType)
{
- XmlSchema schema = GetSchema (xmlMembersMapping.Namespace);
ClassMap cmap = (ClassMap) xmlMembersMapping.ObjectMap;
if (xmlMembersMapping.HasWrapperElement && exportEnclosingType)
{
+ XmlSchema schema = GetSchema (xmlMembersMapping.Namespace);
XmlSchemaComplexType stype = new XmlSchemaComplexType ();
XmlSchemaSequence particle;
ICollection members = cmap.ElementMembers;
if (members != null)
{
- XmlSchemaObjectCollection itemsCol = schema.Items;
-
- // In encoded format, the schema elements are not needed
- if (encodedFormat) itemsCol = new XmlSchemaObjectCollection ();
-
foreach (XmlTypeMapMemberElement member in members)
{
- XmlSchemaElement exe = FindElement (itemsCol, ((XmlTypeMapElementInfo)member.ElementInfo [0]).ElementName);
+ if (member is XmlTypeMapMemberAnyElement && member.TypeData.IsListType)
+ {
+ XmlSchema mschema = GetSchema (xmlMembersMapping.Namespace);
+ XmlSchemaParticle par = GetSchemaArrayElement (mschema, member.ElementInfo);
+ if (par is XmlSchemaAny)
+ {
+ XmlSchemaComplexType ct = FindComplexType (mschema.Items, "any");
+ if (ct != null) continue;
+
+ ct = new XmlSchemaComplexType ();
+ ct.Name = "any";
+ ct.IsMixed = true;
+ XmlSchemaSequence seq = new XmlSchemaSequence ();
+ ct.Particle = seq;
+ seq.Items.Add (par);
+ mschema.Items.Add (ct);
+ continue;
+ }
+ }
+
+
+ XmlTypeMapElementInfo einfo = (XmlTypeMapElementInfo) member.ElementInfo [0];
+ XmlSchema schema;
+
+ if (encodedFormat)
+ {
+ schema = GetSchema (xmlMembersMapping.Namespace);
+ ImportNamespace (schema, XmlSerializer.EncodingNamespace);
+ }
+ else
+ schema = GetSchema (einfo.Namespace);
+
+
+ XmlSchemaElement exe = FindElement (schema.Items, einfo.ElementName);
XmlSchemaElement elem;
Type memType = member.GetType();
if (member is XmlTypeMapMemberFlatList)
throw new InvalidOperationException ("Unwrapped arrays not supported as parameters");
else if (memType == typeof(XmlTypeMapMemberElement))
- elem = (XmlSchemaElement) AddSchemaElement (itemsCol, schema, (XmlTypeMapElementInfo) member.ElementInfo [0], member.DefaultValue, false);
+ elem = (XmlSchemaElement) GetSchemaElement (schema, einfo, member.DefaultValue, false);
else
- elem = (XmlSchemaElement) AddSchemaElement (itemsCol, schema, (XmlTypeMapElementInfo) member.ElementInfo [0], false);
-
+ elem = (XmlSchemaElement) GetSchemaElement (schema, einfo, false);
+
+ // In encoded format, the schema elements are not needed
+ if (!encodedFormat)
+ schema.Items.Add (elem);
+
if (exe != null)
{
if (exe.SchemaTypeName.Equals (elem.SchemaTypeName))
- itemsCol.Remove (elem);
+ schema.Items.Remove (elem);
else
{
- string s = "The XML element named '" + ((XmlTypeMapElementInfo)member.ElementInfo [0]).ElementName + "' ";
+ string s = "The XML element named '" + einfo.ElementName + "' ";
s += "from namespace '" + schema.TargetNamespace + "' references distinct types " + elem.SchemaTypeName.Name + " and " + exe.SchemaTypeName.Name + ". ";
s += "Use XML attributes to specify another XML name or namespace for the element or types.";
throw new InvalidOperationException (s);
}
}
- if (encodedFormat)
- ImportNamespace (schema, XmlSerializer.EncodingNamespace);
-
CompileSchemas ();
}
if (xmlTypeMapping.TypeData.IsComplexType)
einfo.MappedType = xmlTypeMapping;
einfo.IsNullable = false;
- AddSchemaElement (schema.Items, schema, einfo, false);
+ schema.Items.Add (GetSchemaElement (schema, einfo, false));
SetElementExported (xmlTypeMapping);
}
Type memType = member.GetType();
if (memType == typeof(XmlTypeMapMemberFlatList))
{
- AddSchemaArrayElement (seq.Items, schema, member.ElementInfo);
+ seq.Items.Add (GetSchemaArrayElement (schema, member.ElementInfo));
}
else if (memType == typeof(XmlTypeMapMemberAnyElement))
{
- AddSchemaArrayElement (seq.Items, schema, member.ElementInfo);
+ seq.Items.Add (GetSchemaArrayElement (schema, member.ElementInfo));
}
else if (memType == typeof(XmlTypeMapMemberElement))
{
- XmlSchemaElement selem = (XmlSchemaElement) AddSchemaElement (seq.Items, schema, (XmlTypeMapElementInfo) member.ElementInfo [0], member.DefaultValue, true);
+ seq.Items.Add (GetSchemaElement (schema, (XmlTypeMapElementInfo) member.ElementInfo [0], member.DefaultValue, true));
}
else
{
- AddSchemaElement (seq.Items, schema, (XmlTypeMapElementInfo) member.ElementInfo [0], true);
+ seq.Items.Add (GetSchemaElement (schema, (XmlTypeMapElementInfo) member.ElementInfo [0], true));
}
}
}
{
foreach (XmlTypeMapMemberAttribute attr in attributes) {
if (baseMap != null && DefinedInBaseMap (baseMap, attr)) continue;
- outAttributes.Add (GetSchemaAttribute (schema, attr));
+ outAttributes.Add (GetSchemaAttribute (schema, attr, true));
}
}
return null;
}
- XmlSchemaAttribute GetSchemaAttribute (XmlSchema currentSchema, XmlTypeMapMemberAttribute attinfo)
+ XmlSchemaComplexType FindComplexType (XmlSchemaObjectCollection col, string name)
+ {
+ foreach (XmlSchemaObject ob in col)
+ {
+ XmlSchemaComplexType ctype = ob as XmlSchemaComplexType;
+ if (ctype != null && ctype.Name == name) return ctype;
+ }
+ return null;
+ }
+
+ XmlSchemaAttribute GetSchemaAttribute (XmlSchema currentSchema, XmlTypeMapMemberAttribute attinfo, bool isTypeMember)
{
XmlSchemaAttribute sat = new XmlSchemaAttribute ();
if (attinfo.DefaultValue != System.DBNull.Value) sat.DefaultValue = XmlCustomFormatter.ToXmlString (attinfo.TypeData, attinfo.DefaultValue);
ImportNamespace (currentSchema, attinfo.Namespace);
- XmlSchema memberSchema = GetSchema (attinfo.Namespace);
+ XmlSchema memberSchema;
+ if (attinfo.Namespace.Length == 0 && attinfo.Form != XmlSchemaForm.Qualified)
+ memberSchema = currentSchema;
+ else
+ memberSchema = GetSchema (attinfo.Namespace);
+
if (currentSchema == memberSchema || encodedFormat)
{
sat.Name = attinfo.AttributeName;
+ if (isTypeMember) sat.Form = attinfo.Form;
if (attinfo.TypeData.SchemaType == SchemaTypes.Enum)
{
ImportNamespace (currentSchema, attinfo.DataTypeNamespace);
if (ob is XmlSchemaAttribute && ((XmlSchemaAttribute)ob).Name == attinfo.AttributeName)
return sat;
- memberSchema.Items.Add (GetSchemaAttribute (memberSchema, attinfo));
+ memberSchema.Items.Add (GetSchemaAttribute (memberSchema, attinfo, false));
}
return sat;
}
- XmlSchemaParticle AddSchemaElement (XmlSchemaObjectCollection destcol, XmlSchema currentSchema, XmlTypeMapElementInfo einfo, bool isTypeMember)
+ XmlSchemaParticle GetSchemaElement (XmlSchema currentSchema, XmlTypeMapElementInfo einfo, bool isTypeMember)
{
- return AddSchemaElement (destcol, currentSchema, einfo, System.DBNull.Value, isTypeMember);
+ return GetSchemaElement (currentSchema, einfo, System.DBNull.Value, isTypeMember);
}
- XmlSchemaParticle AddSchemaElement (XmlSchemaObjectCollection destcol, XmlSchema currentSchema, XmlTypeMapElementInfo einfo, object defaultValue, bool isTypeMember)
+ XmlSchemaParticle GetSchemaElement (XmlSchema currentSchema, XmlTypeMapElementInfo einfo, object defaultValue, bool isTypeMember)
{
if (einfo.IsTextElement) return null;
XmlSchemaAny any = new XmlSchemaAny ();
any.MinOccurs = 0;
any.MaxOccurs = 1;
- destcol.Add (any);
return any;
}
XmlSchemaElement selem = new XmlSchemaElement ();
- destcol.Add (selem);
if (isTypeMember)
{
if (ob is XmlSchemaElement && ((XmlSchemaElement)ob).Name == einfo.ElementName)
return selem;
- AddSchemaElement (memberSchema.Items, memberSchema, einfo, defaultValue, false);
+ memberSchema.Items.Add (GetSchemaElement (memberSchema, einfo, defaultValue, false));
}
return selem;
}
return stype;
}
- XmlSchemaParticle AddSchemaArrayElement (XmlSchemaObjectCollection destcol, XmlSchema currentSchema, XmlTypeMapElementInfoList infos)
+ XmlSchemaParticle GetSchemaArrayElement (XmlSchema currentSchema, XmlTypeMapElementInfoList infos)
{
int numInfos = infos.Count;
if (numInfos > 0 && ((XmlTypeMapElementInfo)infos[0]).IsTextElement) numInfos--;
if (numInfos == 1)
{
- XmlSchemaParticle selem = AddSchemaElement (destcol, currentSchema, (XmlTypeMapElementInfo) infos[infos.Count-1], true);
+ XmlSchemaParticle selem = GetSchemaElement (currentSchema, (XmlTypeMapElementInfo) infos[infos.Count-1], true);
selem.MinOccursString = "0";
selem.MaxOccursString = "unbounded";
return selem;
else
{
XmlSchemaChoice schoice = new XmlSchemaChoice ();
- destcol.Add (schoice);
schoice.MinOccursString = "0";
schoice.MaxOccursString = "unbounded";
foreach (XmlTypeMapElementInfo einfo in infos)
{
if (einfo.IsTextElement) continue;
- AddSchemaElement (schoice.Items, currentSchema, einfo, true);
+ schoice.Items.Add (GetSchemaElement (currentSchema, einfo, true));
}
return schoice;
}
stype.Name = map.ElementName;
schema.Items.Add (stype);
- XmlSchemaSequence seq = new XmlSchemaSequence ();
- XmlSchemaParticle spart = AddSchemaArrayElement (seq.Items, schema, lmap.ItemInfo);
+ XmlSchemaParticle spart = GetSchemaArrayElement (schema, lmap.ItemInfo);
if (spart is XmlSchemaChoice)
stype.Particle = spart;
else
+ {
+ XmlSchemaSequence seq = new XmlSchemaSequence ();
+ seq.Items.Add (spart);
stype.Particle = seq;
+ }
return new XmlQualifiedName (map.XmlType, map.XmlTypeNamespace);
}
\r
public XmlMembersMapping ImportAnyType (XmlQualifiedName typeName, string elementName)\r
{\r
- XmlTypeMapMemberAnyElement mapMem = new XmlTypeMapMemberAnyElement ();\r
- mapMem.Name = typeName.Name;\r
- mapMem.TypeData = TypeTranslator.GetTypeData(typeof(XmlNode));\r
- mapMem.ElementInfo.Add (CreateElementInfo (typeName.Namespace, mapMem, typeName.Name, mapMem.TypeData, true));\r
- \r
- XmlMemberMapping[] mm = new XmlMemberMapping [1];\r
- mm[0] = new XmlMemberMapping (typeName.Name, typeName.Namespace, mapMem, encodedFormat);\r
- return new XmlMembersMapping (mm);\r
+ if (typeName == XmlQualifiedName.Empty)\r
+ {\r
+ XmlTypeMapMemberAnyElement mapMem = new XmlTypeMapMemberAnyElement ();\r
+ mapMem.Name = typeName.Name;\r
+ mapMem.TypeData = TypeTranslator.GetTypeData(typeof(XmlNode));\r
+ mapMem.ElementInfo.Add (CreateElementInfo (typeName.Namespace, mapMem, typeName.Name, mapMem.TypeData, true));\r
+ \r
+ XmlMemberMapping[] mm = new XmlMemberMapping [1];\r
+ mm[0] = new XmlMemberMapping (typeName.Name, typeName.Namespace, mapMem, encodedFormat);\r
+ return new XmlMembersMapping (mm);\r
+ }\r
+ else\r
+ {\r
+ XmlSchemaComplexType stype = (XmlSchemaComplexType) schemas.Find (typeName, typeof (XmlSchemaComplexType));\r
+ if (stype == null) \r
+ throw new InvalidOperationException ("Referenced type '" + typeName + "' not found");\r
+ \r
+ if (!CanBeAnyElement (stype))\r
+ throw new InvalidOperationException ("The type '" + typeName + "' is not valid for a collection of any elements");\r
+ \r
+ ClassMap cmap = new ClassMap ();\r
+ CodeIdentifiers classIds = new CodeIdentifiers ();\r
+ bool isMixed = stype.IsMixed;\r
+ ImportSequenceContent (typeName, cmap, ((XmlSchemaSequence) stype.Particle).Items, classIds, false, ref isMixed);\r
+ XmlTypeMapMemberAnyElement mapMem = (XmlTypeMapMemberAnyElement) cmap.AllMembers[0];\r
+ mapMem.Name = typeName.Name;\r
+ \r
+ XmlMemberMapping[] mm = new XmlMemberMapping [1];\r
+ mm[0] = new XmlMemberMapping (typeName.Name, typeName.Namespace, mapMem, encodedFormat);\r
+ return new XmlMembersMapping (mm);\r
+ }\r
}\r
\r
public XmlTypeMapping ImportDerivedTypeMapping (XmlQualifiedName name, Type baseType)\r
}\r
else if (CanBeAnyElement (stype))\r
{\r
- return GetTypeMapping (TypeTranslator.GetTypeData(typeof(XmlElement)));\r
+ if (stype.IsMixed)\r
+ return GetTypeMapping (TypeTranslator.GetTypeData(typeof(XmlNode)));\r
+ else\r
+ return GetTypeMapping (TypeTranslator.GetTypeData(typeof(XmlElement)));\r
}\r
else if (CanBeIXmlSerializable (stype))\r
{\r
{\r
ClassMap cmap = new ClassMap ();\r
CodeIdentifiers classIds = new CodeIdentifiers();\r
- ImportParticleComplexContent (typeQName, cmap, stype.Particle, classIds, false);\r
+ ImportParticleComplexContent (typeQName, cmap, stype.Particle, classIds, stype.IsMixed);\r
\r
XmlTypeMapMemberFlatList list = (cmap.AllMembers.Count == 1) ? cmap.AllMembers[0] as XmlTypeMapMemberFlatList : null;\r
if (list != null && list.ChoiceMember == null)\r
XmlTypeMapMemberAnyElement member = new XmlTypeMapMemberAnyElement ();\r
member.Name = classIds.AddUnique ("Any", member);\r
member.Documentation = GetDocumentation (elem);\r
-\r
+ \r
Type ctype;\r
- if (elem.MaxOccurs > 1 || multiValue)\r
+ if (elem.MaxOccurs != 1 || multiValue)\r
ctype = isMixed ? typeof(XmlNode[]) : typeof(XmlElement[]);\r
else\r
ctype = isMixed ? typeof(XmlNode) : typeof(XmlElement);\r
}\r
}\r
}\r
-\r
-\r
+ \r
void ImportChoiceContent (XmlQualifiedName typeQName, ClassMap cmap, XmlSchemaChoice choice, CodeIdentifiers classIds, bool multiValue)\r
{\r
XmlTypeMapElementInfoList choices = new XmlTypeMapElementInfoList ();\r
if (!attr.RefName.IsEmpty)\r
{\r
ns = attr.RefName.Namespace;\r
- return FindRefAttribute (attr.RefName);\r
+ XmlSchemaAttribute at = FindRefAttribute (attr.RefName);\r
+ if (at == null) throw new InvalidOperationException ("The attribute " + attr.RefName + " is missing");\r
+ return at;\r
}\r
else\r
{\r
}
}
else
- ReadMembers ((ClassMap)typeMap.ObjectMap, parameters, true, true);
+ ReadMembers ((ClassMap)typeMap.ObjectMap, parameters, true, _format == SerializationFormat.Encoded);
if (_format == SerializationFormat.Encoded)
ReadReferencedElements();