public override void FixtureInit()
		{
			// Note element path.
			noteElementPath = new XmlElementPath();
			QualifiedName noteQualifiedName = new QualifiedName("note", "http://www.w3schools.com");
			noteElementPath.Elements.Add(noteQualifiedName);
		
			// Text element path.
			textElementPath = new XmlElementPath();
			textElementPath.Elements.Add(noteQualifiedName);
			textElementPath.Elements.Add(new QualifiedName("text", "http://www.w3schools.com"));
		}	
		public CompletionDataList GetAttributeValueCompletionData (XmlElementPath path, string name)
		{
			return new CompletionDataList ();
		}
		public CompletionDataList GetAttributeCompletionData (XmlElementPath path)
		{
			return GetCompletions (attributeCompletions, path, XmlCompletionData.DataType.XmlAttribute);
		}
		public CompletionDataList GetChildElementCompletionData (XmlElementPath path)
		{
			return GetCompletions (elementCompletions, path, XmlCompletionData.DataType.XmlElement);
		}
		static CompletionDataList GetCompletions (Dictionary<string,HashSet<string>> map, XmlElementPath path, XmlCompletionData.DataType type)
		{
			if (path == null || path.Elements.Count == 0)
				return new CompletionDataList ();
			return GetCompletions (map, path.Elements[path.Elements.Count - 1].Name, type);
		}
Esempio n. 6
0
 public CompletionData[] GetAttributeValueCompletionData(XmlElementPath path, string name)
 {
     return(new CompletionData [0]);
 }
Esempio n. 7
0
        public void FixtureInit()
        {
            XmlTextReader reader = ResourceManager.GetXsdSchema();

            schemaCompletionData = new XmlSchemaCompletionData(reader);

            // Set up choice element's path.
            choicePath = new XmlElementPath();
            choicePath.Elements.Add(new QualifiedName("schema", namespaceURI, prefix));
            choicePath.Elements.Add(new QualifiedName("element", namespaceURI, prefix));
            choicePath.Elements.Add(new QualifiedName("complexType", namespaceURI, prefix));

            mixedAttributeValues = schemaCompletionData.GetAttributeValueCompletionData(choicePath, "mixed");

            choicePath.Elements.Add(new QualifiedName("choice", namespaceURI, prefix));

            // Get choice element info.
            choiceAttributes         = schemaCompletionData.GetAttributeCompletionData(choicePath);
            maxOccursAttributeValues = schemaCompletionData.GetAttributeValueCompletionData(choicePath, "maxOccurs");

            // Set up element path.
            elementPath = new XmlElementPath();
            elementPath.Elements.Add(new QualifiedName("schema", namespaceURI, prefix));

            elementFormDefaultAttributeValues = schemaCompletionData.GetAttributeValueCompletionData(elementPath, "elementFormDefault");
            blockDefaultAttributeValues       = schemaCompletionData.GetAttributeValueCompletionData(elementPath, "blockDefault");
            finalDefaultAttributeValues       = schemaCompletionData.GetAttributeValueCompletionData(elementPath, "finalDefault");

            elementPath.Elements.Add(new QualifiedName("element", namespaceURI, prefix));

            // Get element attribute info.
            elementAttributes = schemaCompletionData.GetAttributeCompletionData(elementPath);

            // Set up simple enum type path.
            simpleEnumPath = new XmlElementPath();
            simpleEnumPath.Elements.Add(new QualifiedName("schema", namespaceURI, prefix));
            simpleEnumPath.Elements.Add(new QualifiedName("simpleType", namespaceURI, prefix));
            simpleEnumPath.Elements.Add(new QualifiedName("restriction", namespaceURI, prefix));

            // Get child elements.
            simpleEnumElements = schemaCompletionData.GetChildElementCompletionData(simpleEnumPath);

            // Set up enum path.
            enumPath = new XmlElementPath();
            enumPath.Elements.Add(new QualifiedName("schema", namespaceURI, prefix));
            enumPath.Elements.Add(new QualifiedName("simpleType", namespaceURI, prefix));
            enumPath.Elements.Add(new QualifiedName("restriction", namespaceURI, prefix));
            enumPath.Elements.Add(new QualifiedName("enumeration", namespaceURI, prefix));

            // Get attributes.
            enumAttributes = schemaCompletionData.GetAttributeCompletionData(enumPath);

            // Set up xs:all path.
            allElementPath = new XmlElementPath();
            allElementPath.Elements.Add(new QualifiedName("schema", namespaceURI, prefix));
            allElementPath.Elements.Add(new QualifiedName("element", namespaceURI, prefix));
            allElementPath.Elements.Add(new QualifiedName("complexType", namespaceURI, prefix));
            allElementPath.Elements.Add(new QualifiedName("all", namespaceURI, prefix));

            // Get child elements of the xs:all element.
            allElementChildElements = schemaCompletionData.GetChildElementCompletionData(allElementPath);

            // Set up the path to the annotation element that is a child of xs:all.
            allElementAnnotationPath = new XmlElementPath();
            allElementAnnotationPath.Elements.Add(new QualifiedName("schema", namespaceURI, prefix));
            allElementAnnotationPath.Elements.Add(new QualifiedName("element", namespaceURI, prefix));
            allElementAnnotationPath.Elements.Add(new QualifiedName("complexType", namespaceURI, prefix));
            allElementAnnotationPath.Elements.Add(new QualifiedName("all", namespaceURI, prefix));
            allElementAnnotationPath.Elements.Add(new QualifiedName("annotation", namespaceURI, prefix));

            // Get the xs:all annotation child element.
            allElementAnnotationChildElements = schemaCompletionData.GetChildElementCompletionData(allElementAnnotationPath);
        }
		/// <summary>
		/// Gets the autocomplete data for the specified attribute value.
		/// </summary>
		public CompletionDataList GetAttributeValueCompletionData (XmlElementPath path, string name)
		{
			EnsureLoaded ();
			
			var data = new XmlCompletionDataList (path.Namespaces);
			var element = FindElement (path);
			if (element != null)
				GetAttributeValueCompletionData (data, element, name);
			return data;
		}
        /// <summary>
        /// Finds the schema given the xml element path.
        /// </summary>
        public XmlSchemaCompletionData FindSchema(IXmlSchemaCompletionDataCollection schemaCompletionDataItems, XmlElementPath path)

        {
            if (path.Elements.Count > 0)
            {
                string namespaceUri = path.Elements[0].Namespace;

                if (namespaceUri.Length > 0)
                {
                    return(schemaCompletionDataItems[namespaceUri]);
                }
                else if (defaultSchemaCompletionData != null)
                {
                    // Use the default schema namespace if none

                    // specified in a xml element path, otherwise

                    // we will not find any attribute or element matches

                    // later.

                    foreach (QualifiedName name in path.Elements)
                    {
                        if (name.Namespace.Length == 0)
                        {
                            name.Namespace = defaultSchemaCompletionData.NamespaceUri;
                        }
                    }

                    return(defaultSchemaCompletionData);
                }
            }

            return(null);
        }
 public XmlSchemaCompletionData FindSchema(XmlElementPath path)
 {
     return(FindSchema(XmlSchemaManager.SchemaCompletionDataItems, path));
 }
 public void Init()
 {
     path          = new XmlElementPath();
     qualifiedName = new QualifiedName("foo", "http://foo");
     path.Elements.Add(qualifiedName);
 }
 public void Init()
 {
     path         = new XmlElementPath();
     fooNamespace = new XmlNamespace("foo", "http://foo");
     barNamespace = new XmlNamespace("bar", "http://bar");
 }
Esempio n. 13
0
        public void Equality()
        {
            XmlElementPath newPath = new XmlElementPath();

            Assert.IsTrue(newPath.Equals(path), "Should be equal.");
        }
Esempio n. 14
0
 public void FixtureSetUp()
 {
     path = new XmlElementPath();
 }
		/// <summary>
		/// Gets the attribute completion data for the xml element that exists
		/// at the end of the specified path.
		/// </summary>
		public CompletionDataList GetAttributeCompletionData (XmlElementPath path)
		{
			EnsureLoaded ();
			
			var data = new XmlCompletionDataList (path.Namespaces);
			var element = FindElement (path);
			if (element != null) {
				prohibitedAttributes.Clear ();
				GetAttributeCompletionData (data, element);
			}
			return data;
		}
		/// <summary>
		/// Gets the child element completion data for the xml element that exists
		/// at the end of the specified path.
		/// </summary>
		public CompletionDataList GetChildElementCompletionData (XmlElementPath path)
		{
			EnsureLoaded ();
			
			var data = new XmlCompletionDataList (path.Namespaces);
			var element = FindElement (path);
			if (element != null)
				GetChildElementCompletionData (data, element, path.Elements.LastPrefix);
			return data;
		}		
        public void Init()
        {
            XmlElementPath path = new XmlElementPath();

            paths = new XmlElementPathsByNamespace(path);
        }
 		/// <summary>
		/// Finds the element that exists at the specified path.
		/// </summary>
		/// <remarks>This method is not used when generating completion data,
		/// but is a useful method when locating an element so we can jump
		/// to its schema definition.</remarks>
		/// <returns><see langword="null"/> if no element can be found.</returns>
		public XmlSchemaElement FindElement (XmlElementPath path)
		{
			EnsureLoaded ();
			
			XmlSchemaElement element = null;
			for (int i = 0; i < path.Elements.Count; ++i) {
				QualifiedName name = path.Elements[i];
				if (i == 0) {
					// Look for root element.
					element = FindElement (name);
					if (element == null) {
						break;
					}
				} else {
					element = FindChildElement (element, name);
					if (element == null) {
						break;
					}
				}
			}
			return element;
		}
Esempio n. 19
0
 public CompletionData[] GetAttributeCompletionData(XmlElementPath path)
 {
     return(GetCompletions(attributeCompletions, path, XmlCompletionData.DataType.XmlAttribute));
 }