示例#1
0
 /// <summary>
 ///   Adds the contents of another <see cref='XmlCompletionDataCollection'/> to the end of the collection.
 /// </summary>
 /// <param name='val'>
 ///    A <see cref='XmlCompletionDataCollection'/> containing the objects to add to the collection.
 /// </param>
 /// <seealso cref='XmlCompletionDataCollection.Add'/>
 public void AddRange(XmlCompletionDataCollection val)
 {
     for (int i = 0; i < val.Count; i++)
     {
         this.Add(val[i]);
     }
 }
示例#2
0
 /// <summary>
 /// Adds an element completion data to the collection if it does not 
 /// already exist.
 /// </summary>
 void AddElement(XmlCompletionDataCollection data, string name, string prefix, string documentation)
 {
     if (!data.Contains(name))
     {
         if (prefix.Length > 0)
         {
             name = String.Concat(prefix, ":", name);
         }
         XmlCompletionData completionData = new XmlCompletionData(name, documentation);
         data.Add(completionData);
     }
 }
示例#3
0
 /// <summary>
 /// Adds an attribute value to the completion data collection.
 /// </summary>
 void AddAttributeValue(XmlCompletionDataCollection data, string valueText, XmlSchemaAnnotation annotation)
 {
     string documentation = GetDocumentation(annotation);
     XmlCompletionData completionData = new XmlCompletionData(valueText, documentation, XmlCompletionData.DataType.XmlAttributeValue);
     data.Add(completionData);
 }
示例#4
0
        /// <summary>
        /// Gets the possible root elements for an xml document using this schema.
        /// </summary>
        public ICompletionData[] GetElementCompletionData(string namespacePrefix)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            foreach (XmlSchemaElement element in schema.Elements.Values)
            {
                if (element.Name != null)
                {
                    AddElement(data, element.Name, namespacePrefix, element.Annotation);
                }
                else
                {
                    // Do not add reference element.
                }
            }

            return data.ToArray();
        }
示例#5
0
        /// <summary>
        /// Gets the autocomplete data for the specified attribute value.
        /// </summary>
        public ICompletionData[] GetAttributeValueCompletionData(XmlElementPath path, string name)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            // Locate matching element.
            XmlSchemaElement element = FindElement(path);

            // Get completion data.
            if (element != null)
            {
                data = GetAttributeValueCompletionData(element, name);
            }

            return data.ToArray();
        }
示例#6
0
        XmlCompletionDataCollection GetChildElementCompletionData(XmlSchemaComplexContentRestriction restriction, string prefix)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            // Add any elements.
            if (restriction.Particle != null)
            {
                XmlSchemaSequence sequence = restriction.Particle as XmlSchemaSequence;
                XmlSchemaChoice choice = restriction.Particle as XmlSchemaChoice;
                XmlSchemaGroupRef groupRef = restriction.Particle as XmlSchemaGroupRef;

                if (sequence != null)
                {
                    data = GetChildElementCompletionData(sequence.Items, prefix);
                }
                else if (choice != null)
                {
                    data = GetChildElementCompletionData(choice.Items, prefix);
                }
                else if (groupRef != null)
                {
                    data = GetChildElementCompletionData(groupRef, prefix);
                }
            }

            return data;
        }
示例#7
0
        XmlCompletionDataCollection GetChildElementCompletionData(XmlSchemaComplexContentExtension extension, string prefix)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            XmlSchemaComplexType complexType = FindNamedType(schema, extension.BaseTypeName);
            if (complexType != null)
            {
                data = GetChildElementCompletionData(complexType, prefix);
            }

            // Add any elements.
            if (extension.Particle != null)
            {
                XmlSchemaSequence sequence = extension.Particle as XmlSchemaSequence;
                XmlSchemaChoice choice = extension.Particle as XmlSchemaChoice;
                XmlSchemaGroupRef groupRef = extension.Particle as XmlSchemaGroupRef;

                if (sequence != null)
                {
                    data.AddRange(GetChildElementCompletionData(sequence.Items, prefix));
                }
                else if (choice != null)
                {
                    data.AddRange(GetChildElementCompletionData(choice.Items, prefix));
                }
                else if (groupRef != null)
                {
                    data.AddRange(GetChildElementCompletionData(groupRef, prefix));
                }
            }

            return data;
        }
示例#8
0
        XmlCompletionDataCollection GetChildElementCompletionData(XmlSchemaObjectCollection items, string prefix)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            foreach (XmlSchemaObject schemaObject in items)
            {

                XmlSchemaElement childElement = schemaObject as XmlSchemaElement;
                XmlSchemaSequence childSequence = schemaObject as XmlSchemaSequence;
                XmlSchemaChoice childChoice = schemaObject as XmlSchemaChoice;
                XmlSchemaGroupRef groupRef = schemaObject as XmlSchemaGroupRef;

                if (childElement != null)
                {
                    string name = childElement.Name;
                    if (name == null)
                    {
                        name = childElement.RefName.Name;
                        XmlSchemaElement element = FindElement(childElement.RefName);
                        if (element != null)
                        {
                            if (element.IsAbstract)
                            {
                                AddSubstitionGroupElements(data, element.QualifiedName, prefix);
                            }
                            else
                            {
                                AddElement(data, name, prefix, element.Annotation);
                            }
                        }
                        else
                        {
                            AddElement(data, name, prefix, childElement.Annotation);
                        }
                    }
                    else
                    {
                        AddElement(data, name, prefix, childElement.Annotation);
                    }
                }
                else if (childSequence != null)
                {
                    AddElements(data, GetChildElementCompletionData(childSequence.Items, prefix));
                }
                else if (childChoice != null)
                {
                    AddElements(data, GetChildElementCompletionData(childChoice.Items, prefix));
                }
                else if (groupRef != null)
                {
                    AddElements(data, GetChildElementCompletionData(groupRef, prefix));
                }
            }

            return data;
        }
示例#9
0
        /// <summary>
        /// Gets attribute completion data from a group ref.
        /// </summary>
        XmlCompletionDataCollection GetAttributeCompletionData(XmlSchemaAttributeGroupRef groupRef)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();
            XmlSchemaAttributeGroup group = FindAttributeGroup(schema, groupRef.RefName.Name);
            if (group != null)
            {
                data = GetAttributeCompletionData(group.Attributes);
            }

            return data;
        }
示例#10
0
        XmlCompletionDataCollection GetAttributeCompletionData(XmlSchemaObjectCollection attributes)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            foreach (XmlSchemaObject schemaObject in attributes)
            {
                XmlSchemaAttribute attribute = schemaObject as XmlSchemaAttribute;
                XmlSchemaAttributeGroupRef attributeGroupRef = schemaObject as XmlSchemaAttributeGroupRef;
                if (attribute != null)
                {
                    if (!IsProhibitedAttribute(attribute))
                    {
                        AddAttribute(data, attribute);
                    }
                    else
                    {
                        prohibitedAttributes.Add(attribute);
                    }
                }
                else if (attributeGroupRef != null)
                {
                    data.AddRange(GetAttributeCompletionData(attributeGroupRef));
                }
            }
            return data;
        }
示例#11
0
        XmlCompletionDataCollection GetAttributeCompletionData(XmlSchemaSimpleContentExtension extension)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            data.AddRange(GetAttributeCompletionData(extension.Attributes));

            return data;
        }
示例#12
0
        XmlCompletionDataCollection GetAttributeCompletionData(XmlSchemaSimpleContent simpleContent)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            XmlSchemaSimpleContentExtension extension = simpleContent.Content as XmlSchemaSimpleContentExtension;
            if (extension != null)
            {
                data.AddRange(GetAttributeCompletionData(extension));
            }

            return data;
        }
示例#13
0
        XmlCompletionDataCollection GetAttributeCompletionData(XmlSchemaComplexContentExtension extension)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            data.AddRange(GetAttributeCompletionData(extension.Attributes));
            XmlSchemaComplexType baseComplexType = FindNamedType(schema, extension.BaseTypeName);
            if (baseComplexType != null)
            {
                data.AddRange(GetAttributeCompletionData(baseComplexType));
            }

            return data;
        }
示例#14
0
 /// <summary>
 ///   Initializes a new instance of <see cref='XmlCompletionDataCollection'/> based on another <see cref='XmlCompletionDataCollection'/>.
 /// </summary>
 /// <param name='val'>
 ///   A <see cref='XmlCompletionDataCollection'/> from which the contents are copied
 /// </param>
 public XmlCompletionDataCollection(XmlCompletionDataCollection val)
 {
     this.AddRange(val);
 }
示例#15
0
 /// <summary>
 /// Adds elements to the collection if it does not already exist.
 /// </summary>
 void AddElements(XmlCompletionDataCollection lhs, XmlCompletionDataCollection rhs)
 {
     foreach (XmlCompletionData data in rhs)
     {
         if (!lhs.Contains(data))
         {
             lhs.Add(data);
         }
     }
 }
示例#16
0
 /// <summary>
 ///   Initializes a new instance of <see cref='XmlCompletionDataEnumerator'/>.
 /// </summary>
 public XmlCompletionDataEnumerator(XmlCompletionDataCollection mappings)
 {
     this.temp           = ((IEnumerable)(mappings));
     this.baseEnumerator = temp.GetEnumerator();
 }
示例#17
0
        XmlCompletionDataCollection GetAttributeValueCompletionData(XmlSchemaElement element, string name)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            XmlSchemaComplexType complexType = GetElementAsComplexType(element);
            if (complexType != null)
            {
                XmlSchemaAttribute attribute = FindAttribute(complexType, name);
                if (attribute != null)
                {
                    data.AddRange(GetAttributeValueCompletionData(attribute));
                }
            }

            return data;
        }
示例#18
0
        XmlCompletionDataCollection GetChildElementCompletionData(XmlSchemaComplexContent complexContent, string prefix)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            XmlSchemaComplexContentExtension extension = complexContent.Content as XmlSchemaComplexContentExtension;
            if (extension != null)
            {
                data = GetChildElementCompletionData(extension, prefix);
            }
            else
            {
                XmlSchemaComplexContentRestriction restriction = complexContent.Content as XmlSchemaComplexContentRestriction;
                if (restriction != null)
                {
                    data = GetChildElementCompletionData(restriction, prefix);
                }
            }

            return data;
        }
示例#19
0
        XmlCompletionDataCollection GetAttributeValueCompletionData(XmlSchemaAttribute attribute)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            if (attribute.SchemaType != null)
            {
                XmlSchemaSimpleTypeRestriction simpleTypeRestriction = attribute.SchemaType.Content as XmlSchemaSimpleTypeRestriction;
                if (simpleTypeRestriction != null)
                {
                    data.AddRange(GetAttributeValueCompletionData(simpleTypeRestriction));
                }
            }
            else if (attribute.AttributeSchemaType != null)
            {
                XmlSchemaSimpleType simpleType = attribute.AttributeSchemaType as XmlSchemaSimpleType;

                if (simpleType != null)
                {
                    if (simpleType.Name == "boolean")
                    {
                        data.AddRange(GetBooleanAttributeValueCompletionData());
                    }
                    else
                    {
                        data.AddRange(GetAttributeValueCompletionData(simpleType));
                    }
                }
            }

            return data;
        }
示例#20
0
        XmlCompletionDataCollection GetChildElementCompletionData(XmlSchemaGroupRef groupRef, string prefix)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            XmlSchemaGroup group = FindGroup(groupRef.RefName.Name);
            if (group != null)
            {
                XmlSchemaSequence sequence = group.Particle as XmlSchemaSequence;
                XmlSchemaChoice choice = group.Particle as XmlSchemaChoice;

                if (sequence != null)
                {
                    data = GetChildElementCompletionData(sequence.Items, prefix);
                }
                else if (choice != null)
                {
                    data = GetChildElementCompletionData(choice.Items, prefix);
                }
            }

            return data;
        }
示例#21
0
        XmlCompletionDataCollection GetAttributeValueCompletionData(XmlSchemaSimpleTypeRestriction simpleTypeRestriction)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            foreach (XmlSchemaObject schemaObject in simpleTypeRestriction.Facets)
            {
                XmlSchemaEnumerationFacet enumFacet = schemaObject as XmlSchemaEnumerationFacet;
                if (enumFacet != null)
                {
                    AddAttributeValue(data, enumFacet.Value, enumFacet.Annotation);
                }
            }

            return data;
        }
示例#22
0
        /// <summary>
        /// Gets the attribute completion data for the xml element that exists
        /// at the end of the specified path.
        /// </summary>
        public ICompletionData[] GetAttributeCompletionData(XmlElementPath path)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            // Locate matching element.
            XmlSchemaElement element = FindElement(path);

            // Get completion data.
            if (element != null)
            {
                prohibitedAttributes.Clear();
                data = GetAttributeCompletionData(element);
            }

            return data.ToArray();
        }
示例#23
0
        XmlCompletionDataCollection GetAttributeValueCompletionData(XmlSchemaSimpleTypeUnion union)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            foreach (XmlSchemaObject schemaObject in union.BaseTypes)
            {
                XmlSchemaSimpleType simpleType = schemaObject as XmlSchemaSimpleType;
                if (simpleType != null)
                {
                    data.AddRange(GetAttributeValueCompletionData(simpleType));
                }
            }

            return data;
        }
示例#24
0
        /// <summary>
        /// Gets the child element completion data for the xml element that exists
        /// at the end of the specified path.
        /// </summary>
        public ICompletionData[] GetChildElementCompletionData(XmlElementPath path)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            // Locate matching element.
            XmlSchemaElement element = FindElement(path);

            // Get completion data.
            if (element != null)
            {
                data = GetChildElementCompletionData(element, path.Elements.LastPrefix);
            }

            return data.ToArray();
        }
示例#25
0
        XmlCompletionDataCollection GetAttributeValueCompletionData(XmlSchemaSimpleType simpleType)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            XmlSchemaSimpleTypeRestriction simpleTypeRestriction = simpleType.Content as XmlSchemaSimpleTypeRestriction;
            XmlSchemaSimpleTypeUnion union = simpleType.Content as XmlSchemaSimpleTypeUnion;
            XmlSchemaSimpleTypeList list = simpleType.Content as XmlSchemaSimpleTypeList;

            if (simpleTypeRestriction != null)
            {
                data.AddRange(GetAttributeValueCompletionData(simpleTypeRestriction));
            }
            else if (union != null)
            {
                data.AddRange(GetAttributeValueCompletionData(union));
            }
            else if (list != null)
            {
                data.AddRange(GetAttributeValueCompletionData(list));
            }

            return data;
        }
示例#26
0
        /// <summary>
        /// Adds an attribute to the completion data collection.
        /// </summary>
        /// <remarks>
        /// Note the special handling of xml:lang attributes.
        /// </remarks>
        void AddAttribute(XmlCompletionDataCollection data, XmlSchemaAttribute attribute)
        {
            string name = attribute.Name;
            if (name == null)
            {
                if (attribute.RefName.Namespace == "http://www.w3.org/XML/1998/namespace")
                {
                    name = String.Concat("xml:", attribute.RefName.Name);
                }
            }

            if (name != null)
            {
                string documentation = GetDocumentation(attribute.Annotation);
                XmlCompletionData completionData = new XmlCompletionData(name, documentation, XmlCompletionData.DataType.XmlAttribute);
                data.Add(completionData);
            }
        }
示例#27
0
        XmlCompletionDataCollection GetAttributeValueCompletionData(XmlSchemaSimpleTypeList list)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            if (list.ItemType != null)
            {
                data.AddRange(GetAttributeValueCompletionData(list.ItemType));
            }
            else if (list.ItemTypeName != null)
            {
                XmlSchemaSimpleType simpleType = FindSimpleType(list.ItemTypeName);
                if (simpleType != null)
                {
                    data.AddRange(GetAttributeValueCompletionData(simpleType));
                }
            }

            return data;
        }
示例#28
0
 /// <summary>
 /// Adds an attribute value to the completion data collection.
 /// </summary>
 void AddAttributeValue(XmlCompletionDataCollection data, string valueText, string description)
 {
     XmlCompletionData completionData = new XmlCompletionData(valueText, description, XmlCompletionData.DataType.XmlAttributeValue);
     data.Add(completionData);
 }
示例#29
0
        /// <summary>
        /// Gets the set of attribute values for an xs:boolean type.
        /// </summary>
        XmlCompletionDataCollection GetBooleanAttributeValueCompletionData()
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            AddAttributeValue(data, "0");
            AddAttributeValue(data, "1");
            AddAttributeValue(data, "true");
            AddAttributeValue(data, "false");

            return data;
        }
示例#30
0
        /// <summary>
        /// Adds an element completion data to the collection if it does not 
        /// already exist.
        /// </summary>
        void AddElement(XmlCompletionDataCollection data, string name, string prefix, XmlSchemaAnnotation annotation)
        {
            // Get any annotation documentation.
            string documentation = GetDocumentation(annotation);

            AddElement(data, name, prefix, documentation);
        }
示例#31
0
        XmlCompletionDataCollection GetChildElementCompletionData(XmlSchemaElement element, string prefix)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            XmlSchemaComplexType complexType = GetElementAsComplexType(element);

            if (complexType != null)
            {
                data = GetChildElementCompletionData(complexType, prefix);
            }

            return data;
        }
示例#32
0
 /// <summary>
 /// Adds any elements that have the specified substitution group.
 /// </summary>
 void AddSubstitionGroupElements(XmlCompletionDataCollection data, XmlQualifiedName group, string prefix)
 {
     foreach (XmlSchemaElement element in schema.Elements.Values)
     {
         if (element.SubstitutionGroup == group)
         {
             AddElement(data, element.Name, prefix, element.Annotation);
         }
     }
 }
示例#33
0
        XmlCompletionDataCollection GetChildElementCompletionData(XmlSchemaComplexType complexType, string prefix)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            XmlSchemaSequence sequence = complexType.Particle as XmlSchemaSequence;
            XmlSchemaChoice choice = complexType.Particle as XmlSchemaChoice;
            XmlSchemaGroupRef groupRef = complexType.Particle as XmlSchemaGroupRef;
            XmlSchemaComplexContent complexContent = complexType.ContentModel as XmlSchemaComplexContent;
            XmlSchemaAll all = complexType.Particle as XmlSchemaAll;

            if (sequence != null)
            {
                data = GetChildElementCompletionData(sequence.Items, prefix);
            }
            else if (choice != null)
            {
                data = GetChildElementCompletionData(choice.Items, prefix);
            }
            else if (complexContent != null)
            {
                data = GetChildElementCompletionData(complexContent, prefix);
            }
            else if (groupRef != null)
            {
                data = GetChildElementCompletionData(groupRef, prefix);
            }
            else if (all != null)
            {
                data = GetChildElementCompletionData(all.Items, prefix);
            }

            return data;
        }