XmlTypeMapping CreateTypeMapping (TypeData typeData, XmlRootAttribute root, string defaultXmlType, string defaultNamespace)
{
- string rootNamespace = defaultNamespace;
+ bool hasTypeNamespace = !string.IsNullOrEmpty (defaultNamespace);
+ string rootNamespace = null;
string typeNamespace = null;
string elementName;
bool includeInSchema = true;
if (atts.XmlType != null)
{
- if (atts.XmlType.Namespace != null)
+ if (atts.XmlType.Namespace != null) {
typeNamespace = atts.XmlType.Namespace;
+ hasTypeNamespace = true;
+ }
if (atts.XmlType.TypeName != null && atts.XmlType.TypeName != string.Empty)
defaultXmlType = XmlConvert.EncodeLocalName (atts.XmlType.TypeName);
{
if (root.ElementName.Length != 0)
elementName = XmlConvert.EncodeLocalName(root.ElementName);
- if (root.Namespace != null)
+ if (root.Namespace != null) {
rootNamespace = root.Namespace;
+ hasTypeNamespace = true;
+ }
nullable = root.IsNullable;
}
- if (rootNamespace == null) rootNamespace = "";
- if (typeNamespace == null) typeNamespace = rootNamespace;
+ rootNamespace = rootNamespace ?? defaultNamespace ?? string.Empty;
+ typeNamespace = typeNamespace ?? rootNamespace;
XmlTypeMapping map;
switch (typeData.SchemaType) {
typeData, defaultXmlType, typeNamespace);
break;
default:
- map = new XmlTypeMapping (elementName, rootNamespace, typeData, defaultXmlType, typeNamespace);
+ map = new XmlTypeMapping (elementName, rootNamespace, typeData, defaultXmlType, hasTypeNamespace ? typeNamespace : null);
break;
}
if (rmember.XmlAttributes.XmlIgnore) continue;
if (rmember.DeclaringType != null && rmember.DeclaringType != type) {
XmlTypeMapping bmap = ImportClassMapping (rmember.DeclaringType, root, defaultNamespace);
- ns = bmap.XmlTypeNamespace;
+ if (bmap.HasXmlTypeNamespace)
+ ns = bmap.XmlTypeNamespace;
}
try {
internal string XmlTypeNamespace
{
- get { return xmlTypeNamespace; }
+ get { return xmlTypeNamespace ?? string.Empty; }
set { xmlTypeNamespace = value; }
}
+ internal bool HasXmlTypeNamespace
+ {
+ get { return xmlTypeNamespace != null; }
+ }
+
internal ArrayList DerivedTypes
{
get { return _derivedTypes; }
internal XmlTypeMapping GetRealElementMap (string name, string ens)
{
- if (xmlType == name && xmlTypeNamespace == ens) return this;
+ if (xmlType == name && XmlTypeNamespace == ens) return this;
foreach (XmlTypeMapping map in _derivedTypes)
- if (map.xmlType == name && map.xmlTypeNamespace == ens) return map;
+ if (map.xmlType == name && map.XmlTypeNamespace == ens) return map;
return null;
}