Summary description for XmlSchemaObject.
Exemple #1
1
		public static void AddToTable (XmlSchemaObjectTable table, XmlSchemaObject obj,
			XmlQualifiedName qname, ValidationEventHandler h)
		{
			if (table.Contains (qname)) {
				// FIXME: This logic unexpectedly allows 
				// one redefining item and two or more redefining items.
				// FIXME: redefining item is not simple replacement,
				// but much more complex stuff.
				if (obj.isRedefineChild) {	// take precedence.
					if (obj.redefinedObject != null)
						obj.error (h, String.Format ("Named item {0} was already contained in the schema object table.", qname));
					else
						obj.redefinedObject = table [qname];
					table.Set (qname, obj);
				}
				else if (table [qname].isRedefineChild) {
					if (table [qname].redefinedObject != null)
						obj.error (h, String.Format ("Named item {0} was already contained in the schema object table.", qname));
					else
						table [qname].redefinedObject = obj;
					return;	// never add to the table.
				}
				else if (StrictMsCompliant) {
					table.Set (qname, obj);
				}
				else
					obj.error (h, String.Format ("Named item {0} was already contained in the schema object table. {1}",
					                             qname, "Consider setting MONO_STRICT_MS_COMPLIANT to 'yes' to mimic MS implementation."));
			}
			else
				table.Set (qname, obj);
		}
 internal XmlSchemaObject AddItem(XmlSchemaObject item, XmlQualifiedName qname, XmlSchemas schemas)
 {
     if (item == null)
     {
         return null;
     }
     if ((qname == null) || qname.IsEmpty)
     {
         return null;
     }
     string str = item.GetType().Name + ":" + qname.ToString();
     ArrayList list = (ArrayList) this.ObjectCache[str];
     if (list == null)
     {
         list = new ArrayList();
         this.ObjectCache[str] = list;
     }
     for (int i = 0; i < list.Count; i++)
     {
         XmlSchemaObject obj2 = (XmlSchemaObject) list[i];
         if (obj2 == item)
         {
             return obj2;
         }
         if (this.Match(obj2, item, true))
         {
             return obj2;
         }
         this.Warnings.Add(Res.GetString("XmlMismatchSchemaObjects", new object[] { item.GetType().Name, qname.Name, qname.Namespace }));
         this.Warnings.Add("DEBUG:Cached item key:\r\n" + ((string) this.looks[obj2]) + "\r\nnew item key:\r\n" + ((string) this.looks[item]));
     }
     list.Add(item);
     return item;
 }
Exemple #3
1
        protected SymbolEntry AddSymbol(
            XmlQualifiedName qname, XmlSchemaObject schemaObject, string suffix)
        {
            SymbolEntry symbol = new SymbolEntry();
            symbol.xsdNamespace = qname.Namespace;
            symbol.clrNamespace = configSettings.GetClrNamespace(qname.Namespace);
            symbol.symbolName = qname.Name;
            string identifierName = NameGenerator.MakeValidIdentifier(
                symbol.symbolName, this.configSettings.NameMangler2);
            symbol.identifierName = identifierName;
            int id = 0;
            if(symbols.ContainsKey(symbol))
            {
                identifierName = identifierName + suffix;
                symbol.identifierName = identifierName;
                while (symbols.ContainsKey(symbol))
                {
                    id++;
                    symbol.identifierName = identifierName + id.ToString(CultureInfo.InvariantCulture.NumberFormat);
                }
            }
            if(symbol.isNameFixed())
                nFixedNames++;

            symbols.Add(symbol, symbol);
            schemaNameToIdentifiers.Add(schemaObject, symbol.identifierName); //Type vs typeName
            return symbol;
        }
		public override string ImportSchemaType(XmlSchemaType type, XmlSchemaObject context, XmlSchemas schemas, XmlSchemaImporter importer, CodeCompileUnit compileUnit, CodeNamespace mainNamespace, CodeGenerationOptions options, CodeDomProvider codeProvider) {
			if (type == null) {
				return null;
			}

			if (importedTypes[type] != null) {
				mainNamespace.Imports.Add(new CodeNamespaceImport(typeof(DataSet).Namespace));
				compileUnit.ReferencedAssemblies.Add("System.Data.dll");
				return (string)importedTypes[type];
			}
			if (!(context is XmlSchemaElement))
				return null;

			if (type is XmlSchemaComplexType) {
				XmlSchemaComplexType ct = (XmlSchemaComplexType)type;
				if (ct.Particle is XmlSchemaSequence) {
					XmlSchemaObjectCollection items = ((XmlSchemaSequence)ct.Particle).Items;
					if (items.Count == 2 && items[0] is XmlSchemaAny && items[1] is XmlSchemaAny) {
						XmlSchemaAny any0 = (XmlSchemaAny)items[0];
						XmlSchemaAny any1 = (XmlSchemaAny)items[1];
						if (any0.Namespace == XmlSchema.Namespace && any1.Namespace == "urn:schemas-microsoft-com:xml-diffgram-v1") {
							string typeName = typeof(DataTable).FullName;
							importedTypes.Add(type, typeName);
							mainNamespace.Imports.Add(new CodeNamespaceImport(typeof(DataTable).Namespace));
							compileUnit.ReferencedAssemblies.Add("System.Data.dll");
							return typeName;
						}
					}
				}
			}
			return null;
		}
 internal void AddRef(ArrayList list, XmlSchemaObject o)
 {
     if (((((o != null) && !this.schemas.IsReference(o)) && (o.Parent is XmlSchema)) && (((XmlSchema) o.Parent).TargetNamespace != "http://www.w3.org/2001/XMLSchema")) && !list.Contains(o))
     {
         list.Add(o);
     }
 }
        protected internal override void Read(XmlSchemaObject obj)
        {
            var type = (XmlSchemaComplexType) obj;

            if (type.Particle == null)
            {
                throw new InvalidOperationException(string.Format("Missing particle on choice type '{0}'", type.Name));
            }

            var choice = type.Particle as XmlSchemaChoice;

            if (choice == null)
            {
                throw new InvalidOperationException(string.Format("Unexpected particle type '{0}' on choice type '{1}'", type.Particle.GetType(), type.Name));
            }

            MaxOccurs = !string.IsNullOrEmpty(choice.MaxOccursString) ? choice.MaxOccurs : (decimal?) null;

            foreach (var item in choice.Items)
            {
                var element = item as XmlSchemaElement;

                if (element == null)
                {
                    throw new InvalidOperationException(string.Format("Unexpected item type '{0}' on choice type '{1}'", item.GetType(), type.Name));
                }

                var choiceType = new SDataSchemaChoiceItem();
                choiceType.Read(element);
                Types.Add(choiceType);
            }

            base.Read(obj);
        }
Exemple #7
0
		internal override void SetParent (XmlSchemaObject parent)
		{
			base.SetParent (parent);

			foreach (XmlSchemaObject obj in Items)
				obj.SetParent (this);
		}
        public override string ImportSchemaType(
            string name,
            string ns,
            XmlSchemaObject context,
            XmlSchemas schemas,
            XmlSchemaImporter importer,
            CodeCompileUnit compileUnit,
            CodeNamespace mainNamespace,
            CodeGenerationOptions options,
            CodeDomProvider codeProvider)
        {
            if (ns != "http://www.w3.org/2001/XMLSchema")
                return null;

            switch (name)
            {
                case "anyURI":     return "System.Uri"; 
                case "gDay":       return "System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDay";
                case "gMonth":     return "System.Runtime.Remoting.Metadata.W3cXsd2001.SoapMonth";
                case "gMonthDay":  return "System.Runtime.Remoting.Metadata.W3cXsd2001.SoapMonthDay";
                case "gYear":      return "System.Runtime.Remoting.Metadata.W3cXsd2001.SoapYear"; 
                case "gYearMonth": return "System.Runtime.Remoting.Metadata.W3cXsd2001.SoapYearMonth";
                case "duration":   return "System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDuration"; 
                default: return null;
            }
        }
        //public override string ImportSchemaType(
        //    string name, 
        //    string ns, 
        //    XmlSchemaObject context, 
        //    XmlSchemas schemas, 
        //    XmlSchemaImporter importer,
        //    CodeCompileUnit compileUnit, 
        //    CodeNamespace mainNamespace, 
        //    CodeGenerationOptions options, 
        //    CodeDomProvider codeProvider)
        //{

        //    XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType) schemas.Find(new XmlQualifiedName(name, ns), typeof(XmlSchemaSimpleType));
        //    return ImportSchemaType(
        //        simpleType, 
        //        context, 
        //        schemas, 
        //        importer, 
        //        compileUnit, 
        //        mainNamespace, 
        //        options, 
        //        codeProvider);
        //}

        public override string ImportSchemaType(
            XmlSchemaType type, 
            XmlSchemaObject context, 
            XmlSchemas schemas, 
            XmlSchemaImporter importer,
            CodeCompileUnit compileUnit, 
            CodeNamespace mainNamespace, 
            CodeGenerationOptions options, 
            CodeDomProvider codeProvider)
        {

            XmlSchemaAnnotated annotatedType  = type as XmlSchemaAnnotated;
            if (annotatedType == null)
                return null;

            if (annotatedType.Annotation == null)
                return null;

            // create the comments and add them to the hash table under the namespace of the object
            CreateComments(annotatedType);

            //mainNamespace.Types.

            return null;

        }
 private void AddSchemaItem(XmlSchemaObject item, string ns, string referencingNs)
 {
     XmlSchema schema = this.schemas[ns];
     if (schema == null)
     {
         schema = this.AddSchema(ns);
     }
     if (item is XmlSchemaElement)
     {
         XmlSchemaElement element = (XmlSchemaElement) item;
         if (element.Form == XmlSchemaForm.Unqualified)
         {
             throw new InvalidOperationException(Res.GetString("XmlIllegalForm", new object[] { element.Name }));
         }
         element.Form = XmlSchemaForm.None;
     }
     else if (item is XmlSchemaAttribute)
     {
         XmlSchemaAttribute attribute = (XmlSchemaAttribute) item;
         if (attribute.Form == XmlSchemaForm.Unqualified)
         {
             throw new InvalidOperationException(Res.GetString("XmlIllegalForm", new object[] { attribute.Name }));
         }
         attribute.Form = XmlSchemaForm.None;
     }
     schema.Items.Add(item);
     this.AddSchemaImport(ns, referencingNs);
 }
        public DocumentationInfo GetObjectDocumentationInfo(XmlSchemaObject obj)
        {
            var documentationInfo = InternalGetDocumentationInfo(obj);
            if (documentationInfo != null)
                return documentationInfo;

            XmlSchemaElement element;
            if (Casting.TryCast(obj, out element))
            {
                if (!element.RefName.IsEmpty)
                    return GetObjectDocumentationInfo(Context.SchemaSetManager.SchemaSet.GlobalElements[element.RefName]);

                if (element.ElementSchemaType != null && Context.Configuration.UseTypeDocumentationForUndocumentedElements)
                    return GetObjectDocumentationInfo(element.ElementSchemaType);
            }

            XmlSchemaAttribute attribute;
            if (Casting.TryCast(obj, out attribute))
            {
                if (!attribute.RefName.IsEmpty)
                    return GetObjectDocumentationInfo(Context.SchemaSetManager.SchemaSet.GlobalAttributes[attribute.RefName]);

                if (attribute.AttributeSchemaType != null && Context.Configuration.UseTypeDocumentationForUndocumentedAttributes)
                    return GetObjectDocumentationInfo(attribute.AttributeSchemaType);
            }

            return null;
        }
 protected internal override void Read(XmlSchemaObject obj)
 {
     var element = (XmlSchemaElement) obj;
     ElementName = element.Name;
     Type = element.SchemaTypeName;
     base.Read(obj);
 }
        private static string GetName(XmlSchemaObject xmlSchemaObject)
        {
            var isGlobal = xmlSchemaObject.Parent is XmlSchema;

            var soAsAttribute = xmlSchemaObject as XmlSchemaAttribute;
            if (soAsAttribute != null)
                if (isGlobal)
                    return soAsAttribute.QualifiedName.Name;
                else
                    return "@" + soAsAttribute.QualifiedName.Name;

            var soAsElement = xmlSchemaObject as XmlSchemaElement;
            if (soAsElement != null)
                return soAsElement.QualifiedName.Name;

            var soAsGroup = xmlSchemaObject as XmlSchemaGroup;
            if (soAsGroup != null)
                return soAsGroup.QualifiedName.Name;

            var soAsAttributeGroup = xmlSchemaObject as XmlSchemaAttributeGroup;
            if (soAsAttributeGroup != null)
                return soAsAttributeGroup.QualifiedName.Name;

            var soAsComplexType = xmlSchemaObject as XmlSchemaComplexType;
            if (soAsComplexType != null && !soAsComplexType.QualifiedName.IsEmpty)
                return soAsComplexType.QualifiedName.Name;

            return null;
        }
        private static string GetHelpKeyword(XmlSchemaSet schemaSet, string xmlNamespace, XmlSchemaObject xmlSchemaObject)
        {
            var xmlLastObject = xmlSchemaObject;
            var sb = new StringBuilder();
            while (xmlSchemaObject != null && !(xmlSchemaObject is XmlSchema))
            {
                xmlSchemaObject = ResolveLink(schemaSet, xmlSchemaObject);
                var name = GetName(xmlSchemaObject);
                if (name != null)
                {
                    if (sb.Length > 0)
                        sb.Insert(0, "/");
                    sb.Insert(0, name);
                }

                xmlLastObject = xmlSchemaObject;
                xmlSchemaObject = xmlSchemaObject.Parent;
            }

            if (xmlLastObject is XmlSchemaGroup)
                sb.Insert(0, "#G/");
            else if (xmlLastObject is XmlSchemaAttributeGroup)
                sb.Insert(0, "#AG/");
            else if (xmlLastObject is XmlSchemaSimpleType || xmlLastObject is XmlSchemaComplexType)
                sb.Insert(0, "#T/");
            else
                sb.Insert(0, "#E/");

            sb.Insert(0, xmlNamespace ?? String.Empty);
            return sb.ToString();
        }
 public string GetSourceCodeAbridged(XmlSchemaObject obj)
 {
     return InternalGetSourceCode(obj, PostProcessingOptions.RemoveAnnotations |
                                       PostProcessingOptions.CollapseElements |
                                       PostProcessingOptions.CollapseAttributes |
                                       PostProcessingOptions.Format);
 }
 protected internal override void Read(XmlSchemaObject obj)
 {
     var simpleType = (XmlSchemaSimpleType) obj;
     var restriction = (XmlSchemaSimpleTypeRestriction) simpleType.Content;
     BaseType = restriction.BaseTypeName;
     base.Read(obj);
 }
        public override string ImportSchemaType(
            string name, 
            string ns,
            XmlSchemaObject context, 
            XmlSchemas schemas,
            XmlSchemaImporter importer,
            CodeCompileUnit compileUnit, 
            CodeNamespace codeNamespace,
            CodeGenerationOptions options, 
            CodeDomProvider codeGenerator)
        {

            if (IsBaseType(name, ns))
            {
                return base.ImportSchemaType(name, ns,
                context, schemas,
                importer,
                compileUnit, codeNamespace,
                options, codeGenerator);
            }

            // Add the Namespace, except the first
            for (int i = 1; i < ImportNamespaces.Length; i++)
            {
                string _Import = ImportNamespaces[i];
                codeNamespace.Imports.Add(new CodeNamespaceImport(_Import));
            }

            return name;
        }
Exemple #18
0
		static internal XmlQualifiedName ParseWsdlArrayType(string type, out string dims, XmlSchemaObject parent) {
			string ns;
			string name;

			int nsLen = type.LastIndexOf(':');

			if (nsLen <= 0) {
				ns = "";
			}
			else {
				ns = type.Substring(0, nsLen);
			}
			int nameLen = type.IndexOf('[', nsLen + 1);

			if (nameLen <= nsLen) {
				throw new InvalidOperationException(Res.GetString(Res.XmlInvalidArrayTypeSyntax, type));
			}
			name = type.Substring(nsLen + 1, nameLen - nsLen - 1);
			dims = type.Substring(nameLen);

			// parent is not null only in the case when we used XmlSchema.Read(), 
			// in which case we need to fixup the wsdl:arayType attribute value
			while (parent != null) {
				if (parent.Namespaces != null) {
					string wsdlNs = (string)parent.Namespaces.Namespaces[ns];
					if (wsdlNs != null) {
						ns = wsdlNs;
						break;
					}
				}
				parent = parent.Parent;
			}
			return new XmlQualifiedName(name, ns);
		}
        public static void WriteObsoleteInfo(this MamlWriter writer, Context context, XmlSchemaObject obj)
        {
            var documentationInfo = context.DocumentationManager.GetObjectDocumentationInfo(obj);
            if (documentationInfo == null)
                return;

            writer.WriteObsoleteInfo(context, documentationInfo);
        }
		internal override void SetParent (XmlSchemaObject parent)
		{
			base.SetParent (parent);
			if (Selector != null)
				Selector.SetParent (this);
			foreach (XmlSchemaObject obj in Fields)
				obj.SetParent (this);
		}
Exemple #21
0
 /// <include file='doc\XmlSchemaException.uex' path='docs/doc[@for="XmlSchemaException.XmlSchemaException5"]/*' />
 protected XmlSchemaException(SerializationInfo info, StreamingContext context) : base(info, context) {
     res                = (string)         info.GetValue("res"  , typeof(string));
     args               = (string[])       info.GetValue("args", typeof(string[]));
     sourceUri          = (string)         info.GetValue("sourceUri", typeof(string));
     lineNumber         = (int)            info.GetValue("lineNumber", typeof(int));
     linePosition       = (int)            info.GetValue("linePosition", typeof(int));
     sourceSchemaObject = (XmlSchemaObject)info.GetValue("sourceSchemaObject", typeof(XmlSchemaObject));
 }
		internal override void SetParent (XmlSchemaObject parent)
		{
			base.SetParent (parent);
			if (AnyAttribute != null)
				AnyAttribute.SetParent (this);
			foreach (XmlSchemaObject obj in Attributes)
				obj.SetParent (this);
		}
 void ReadLocation(XmlSchemaObject schemaObject)
 {
     if (schemaObject.SourceUri != null) {
         fileName = schemaObject.SourceUri.Replace("file:///", String.Empty);
     }
     lineNumber = schemaObject.LineNumber;
     linePosition = schemaObject.LinePosition;
 }
 private int FindIndexByValue(XmlSchemaObject xso) {
     int index;
     for(index = 0; index < entries.Count; index++) {
         if((object)entries[index].xso == (object)xso) {
             return index;
         }    
     }
     return -1;
 }
Exemple #25
0
		internal override void SetParent (XmlSchemaObject parent)
		{
			base.SetParent (parent);
			foreach (XmlSchemaObject i in Items) {
				i.SetParent (this);
				i.isRedefinedComponent = true;
				i.isRedefineChild = true;
			}
		}
        protected internal override void Read(XmlSchemaObject obj)
        {
            if (obj is XmlSchemaElement)
            {
                ElementName = ((XmlSchemaElement) obj).Name;
            }

            base.Read(obj);
        }
        protected internal override void Write(XmlSchemaObject obj)
        {
            if (obj is XmlSchemaElement)
            {
                ((XmlSchemaElement) obj).Name = ElementName;
            }

            base.Write(obj);
        }
		protected XmlSchemaException(SerializationInfo info, StreamingContext context)
			: base (info, context)
		{
			this.hasLineInfo = info.GetBoolean ("hasLineInfo");
			this.lineNumber = info.GetInt32 ("lineNumber");
			this.linePosition = info.GetInt32 ("linePosition");
			this.sourceUri = info.GetString ("sourceUri");
			this.sourceObj = info.GetValue ("sourceObj", typeof (XmlSchemaObject)) as XmlSchemaObject;
		}
 public override string ImportSchemaType(string name, string xmlNamespace, XmlSchemaObject context, XmlSchemas schemas, XmlSchemaImporter importer, CodeCompileUnit compileUnit, CodeNamespace mainNamespace, CodeGenerationOptions options, CodeDomProvider codeProvider)
 {
     if ((this.m_direct && (context is XmlSchemaElement)) && ((string.CompareOrdinal(this.m_name, name) == 0) && (string.CompareOrdinal(this.m_targetNamespace, xmlNamespace) == 0)))
     {
         compileUnit.ReferencedAssemblies.AddRange(this.m_references);
         mainNamespace.Imports.AddRange(this.m_namespaceImports);
         return this.m_destinationType;
     }
     return null;
 }
        protected internal override void Write(XmlSchemaObject obj)
        {
            var element = obj as XmlSchemaElement;
            if (element != null)
            {
                element.Name = ElementName;
            }

            base.Write(obj);
        }