void SetSchemaXmlSerializableType(XmlSerializableMapping map, XmlSchemaElement elem)
        {
#if NET_2_0
            if (map.SchemaType != null && map.Schema != null)
            {
                elem.SchemaType = map.SchemaType;
                return;
            }

            if (map.SchemaType == null && map.SchemaTypeName != null)
            {
                elem.SchemaTypeName = map.SchemaTypeName;
                elem.Name           = map.SchemaTypeName.Name;
                return;
            }
#endif
            XmlSchemaComplexType stype = new XmlSchemaComplexType();
            XmlSchemaSequence    seq   = new XmlSchemaSequence();
            if (map.Schema == null)
            {
                XmlSchemaElement selem = new XmlSchemaElement();
                selem.RefName = new XmlQualifiedName("schema", XmlSchema.Namespace);
                seq.Items.Add(selem);
                seq.Items.Add(new XmlSchemaAny());
            }
            else
            {
                XmlSchemaAny any = new XmlSchemaAny();
                any.Namespace = map.Schema.TargetNamespace;
                seq.Items.Add(any);
            }
            stype.Particle  = seq;
            elem.SchemaType = stype;
        }
        void ExportXmlSerializableSchema(XmlSchema currentSchema, XmlSerializableMapping map)
        {
            if (IsMapExported(map))
            {
                return;
            }
            SetMapExported(map);

            if (map.Schema == null)
            {
                return;
            }

            string    targetNs       = map.Schema.TargetNamespace;
            XmlSchema existingSchema = schemas [targetNs];

            if (existingSchema == null)
            {
                schemas.Add(map.Schema);
                ImportNamespace(currentSchema, targetNs);
            }
            else if (existingSchema != map.Schema && !CanBeDuplicated(existingSchema, map.Schema))
            {
                throw new InvalidOperationException("The namespace '" + targetNs + "' defined by the class '" + map.TypeFullName + "' is a duplicate.");
            }
        }