void GetChildElementCompletionData(XmlCompletionDataList data, XmlSchemaObjectCollection items, string prefix)
 {
     foreach (XmlSchemaObject schemaObject in items)
     {
         var childElement = schemaObject as XmlSchemaElement;
         if (childElement != null)
         {
             string name = childElement.Name;
             if (name == null)
             {
                 name = childElement.RefName.Name;
                 var element = FindElement(childElement.RefName);
                 if (element != null)
                 {
                     if (element.IsAbstract)
                     {
                         AddSubstitionGroupElements(data, element.QualifiedName, prefix);
                     }
                     else
                     {
                         data.AddElement(name, prefix, element.Annotation);
                     }
                 }
                 else
                 {
                     data.AddElement(name, prefix, childElement.Annotation);
                 }
             }
             else
             {
                 data.AddElement(name, prefix, childElement.Annotation);
             }
             continue;
         }
         var childSequence = schemaObject as XmlSchemaSequence;
         if (childSequence != null)
         {
             GetChildElementCompletionData(data, childSequence.Items, prefix);
             continue;
         }
         var childChoice = schemaObject as XmlSchemaChoice;
         if (childChoice != null)
         {
             GetChildElementCompletionData(data, childChoice.Items, prefix);
             continue;
         }
         var groupRef = schemaObject as XmlSchemaGroupRef;
         if (groupRef != null)
         {
             GetChildElementCompletionData(data, groupRef, prefix);
             continue;
         }
     }
 }
 /// <summary>
 /// Adds any elements that have the specified substitution group.
 /// </summary>
 void AddSubstitionGroupElements(XmlCompletionDataList data, XmlQualifiedName group, string prefix)
 {
     foreach (XmlSchemaElement element in schema.Elements.Values)
     {
         if (element.SubstitutionGroup == group)
         {
             data.AddElement(element.Name, prefix, element.Annotation);
         }
     }
 }
        /// <summary>
        /// Gets the possible root elements for an xml document using this schema.
        /// </summary>
        public CompletionDataList GetElementCompletionData(string namespacePrefix)
        {
            EnsureLoaded();

            var data = new XmlCompletionDataList();

            foreach (XmlSchemaElement element in schema.Elements.Values)
            {
                if (element.Name != null)
                {
                    data.AddElement(element.Name, namespacePrefix, element.Annotation);
                }
                else
                {
                    // Do not add reference element.
                }
            }
            return(data);
        }
Exemplo n.º 4
0
		void GetChildElementCompletionData (XmlCompletionDataList data, XmlSchemaObjectCollection items, string prefix)
		{
			foreach (XmlSchemaObject schemaObject in items) {
				var childElement = schemaObject as XmlSchemaElement;
				if (childElement != null) {
					string name = childElement.Name;
					if (name == null) {
						name = childElement.RefName.Name;
						var element = FindElement (childElement.RefName);
						if (element != null) {
							if (element.IsAbstract) {
								AddSubstitionGroupElements (data, element.QualifiedName, prefix);
							} else {
								data.AddElement (name, prefix, element.Annotation);
							}
						} else {
							data.AddElement (name, prefix, childElement.Annotation);						
						}
					} else {
						data.AddElement (name, prefix, childElement.Annotation);
					}
					continue;
				}
				var childSequence = schemaObject as XmlSchemaSequence;
				if (childSequence != null) {
					GetChildElementCompletionData (data, childSequence.Items, prefix);
					continue;
				}
				var childChoice = schemaObject as XmlSchemaChoice;
				if (childChoice != null) {
					GetChildElementCompletionData (data, childChoice.Items, prefix);
					continue;
				}
				var groupRef = schemaObject as XmlSchemaGroupRef;
				if (groupRef != null) {
					GetChildElementCompletionData (data, groupRef, prefix);
					continue;
				}
			}
		}
Exemplo n.º 5
0
		/// <summary>
		/// Gets the possible root elements for an xml document using this schema.
		/// </summary>
		public CompletionDataList GetElementCompletionData (string namespacePrefix)
		{
			EnsureLoaded ();
			
			var data = new XmlCompletionDataList ();
			foreach (XmlSchemaElement element in schema.Elements.Values) {
				if (element.Name != null) {
					data.AddElement (element.Name, namespacePrefix, element.Annotation);
				} else {
					// Do not add reference element.
				}
			}
			return data;
		}
Exemplo n.º 6
0
		/// <summary>
		/// Adds any elements that have the specified substitution group.
		/// </summary>
		void AddSubstitionGroupElements (XmlCompletionDataList data, XmlQualifiedName group, string prefix)
		{
			foreach (XmlSchemaElement element in schema.Elements.Values)
				if (element.SubstitutionGroup == group)
					data.AddElement (element.Name, prefix, element.Annotation);
		}