public override void FixtureInit()
		{
			XmlElementPath path = new XmlElementPath();
			path.AddElement(new QualifiedName("schema", "http://www.w3.org/2001/XMLSchema"));
			
			schemaChildElements = SchemaCompletion.GetChildElementCompletion(path);
			schemaAttributes = SchemaCompletion.GetAttributeCompletion(path);
			
			// Get include elements attributes.
			path.AddElement(new QualifiedName("include", "http://www.w3.org/2001/XMLSchema"));
			includeAttributes = SchemaCompletion.GetAttributeCompletion(path);
		
			// Get annotation element info.
			path.Elements.RemoveLast();
			path.AddElement(new QualifiedName("annotation", "http://www.w3.org/2001/XMLSchema"));
			
			annotationChildElements = SchemaCompletion.GetChildElementCompletion(path);
			annotationAttributes = SchemaCompletion.GetAttributeCompletion(path);
		
			// Get app info attributes.
			path.AddElement(new QualifiedName("appinfo", "http://www.w3.org/2001/XMLSchema"));
			appInfoAttributes = SchemaCompletion.GetAttributeCompletion(path);
			
			// Get foo attributes.
			path = new XmlElementPath();
			path.AddElement(new QualifiedName("foo", "http://www.w3.org/2001/XMLSchema"));
			fooAttributes = SchemaCompletion.GetAttributeCompletion(path);
		}
		public void Init()
		{
			XmlElementPath path = new XmlElementPath();
			path.AddElement(new QualifiedName("a", "a-namespace"));
			path.AddElement(new QualifiedName("b", "b-namespace"));
			paths = new XmlElementPathsByNamespace(path);
		}
		public override void FixtureInit()
		{
			XmlElementPath path = new XmlElementPath();
			path.AddElement(new QualifiedName("root", "http://foo"));
			path.AddElement(new QualifiedName("bar", "http://foo"));
			barElementAttributes = SchemaCompletion.GetAttributeCompletion(path);
		}
		public void Equality()
		{
			XmlElementPath newPath = new XmlElementPath();
			newPath.AddElement(new QualifiedName("foo", "http://foo", "f"));
			newPath.AddElement(new QualifiedName("bar", "http://bar", "b"));
			
			Assert.IsTrue(newPath.Equals(path), "Should be equal.");
		}
 public void TextHasNoChildElements()
 {
     XmlElementPath path = new XmlElementPath();
     path.AddElement(new QualifiedName("note", "http://www.w3schools.com"));
     path.AddElement(new QualifiedName("text", "http://www.w3schools.com"));
     Assert.AreEqual(0, SchemaCompletion.GetChildElementCompletion(path).Count,
                     "Should be no child elements.");
 }
        public void FirstXmlElementPathHasTwoElements()
        {
            XmlElementPath expectedPath = new XmlElementPath();
            expectedPath.AddElement(new QualifiedName("a", "a-namespace"));
            expectedPath.AddElement(new QualifiedName("aa", "a-namespace"));

            Assert.AreEqual(expectedPath, paths[0]);
        }
		public override void FixtureInit()
		{
			XmlElementPath path = new XmlElementPath();
			path.AddElement(new QualifiedName("project", "http://nant.sf.net//nant-0.84.xsd"));
			path.AddElement(new QualifiedName("attrib", "http://nant.sf.net//nant-0.84.xsd"));
			
			attributes = SchemaCompletion.GetAttributeCompletion(path);
		}
		public void NotEqual()
		{
			XmlElementPath newPath = new XmlElementPath();
			newPath.AddElement(new QualifiedName("aaa", "a", "a"));
			newPath.AddElement(new QualifiedName("bbb", "b", "b"));
			
			Assert.IsFalse(newPath.Equals(path), "Should not be equal.");
		}
		public void Init()
		{
			path = new XmlElementPath();
			firstQualifiedName = new QualifiedName("foo", "http://foo", "f");
			path.AddElement(firstQualifiedName);
			
			secondQualifiedName = new QualifiedName("bar", "http://bar", "b");
			path.AddElement(secondQualifiedName);
		}
        public override void FixtureInit()
        {
            XmlElementPath path = new XmlElementPath();
            path.AddElement(new QualifiedName("person", "http://foo"));
            personElementChildren = SchemaCompletion.GetChildElementCompletion(path);

            path.AddElement(new QualifiedName("firstname", "http://foo"));
            firstNameAttributes = SchemaCompletion.GetAttributeCompletion(path);
            firstNameElementChildren = SchemaCompletion.GetChildElementCompletion(path);
        }
		public void GetActiveElementStartPathForChildElementWithNamespacePrefix()
		{
			string text = "<f:foo xmlns:f='" + namespaceURI + "' ><f:bar ";
			elementPath = XmlParser.GetActiveElementStartPath(text, text.Length);
			
			expectedElementPath = new XmlElementPath();
			expectedElementPath.AddElement(new QualifiedName("foo", namespaceURI, "f"));
			expectedElementPath.AddElement(new QualifiedName("bar", namespaceURI, "f"));
			Assert.IsTrue(expectedElementPath.Equals(elementPath), 
			              "Incorrect active element path.");
		}		
		public void GetParentElementPathForTwoElementsInDifferentNamespaces()
		{
			string text = "<bar xmlns='http://test.com'><foo xmlns='" + namespaceURI + "' ><";
			elementPath = XmlParser.GetParentElementPath(text);
			
			expectedElementPath = new XmlElementPath();
			expectedElementPath.AddElement(new QualifiedName("bar", "http://test.com"));
			expectedElementPath.AddElement(new QualifiedName("foo", namespaceURI));
			Assert.IsTrue(elementPath.Equals(expectedElementPath), 
			              "Incorrect active element path.");
		}
Esempio n. 13
0
		public void GetAttributeCompletion_TemplateElementIsChildOfStylesheetElement_SubstitutionGroupUsedForTemplateAndMatchAttributeReturned()
		{
			var path = new XmlElementPath();
			path.AddElement(new QualifiedName("stylesheet", namespaceURI));
			path.AddElement(new QualifiedName("template", namespaceURI));
			
			XmlCompletionItemCollection completionItems = schemaCompletion.GetAttributeCompletion(path);
			bool contains = completionItems.Contains("match");
			
			Assert.IsTrue(contains);
		}
		public void PathTest3()
		{
			string text = "<foo xmlns='" + namespaceURI + "'><bar>";
			elementPath = XmlParser.GetActiveElementStartPathAtIndex(text, text.IndexOf("ar>"));
			
			expectedElementPath = new XmlElementPath();
			expectedElementPath.AddElement(new QualifiedName("foo", namespaceURI));
			expectedElementPath.AddElement(new QualifiedName("bar", namespaceURI));
			Assert.IsTrue(elementPath.Equals(expectedElementPath), 
			              "Incorrect active element path.");
		}
        public override void FixtureInit()
        {
            // Note element path.
            noteElementPath = new XmlElementPath();
            QualifiedName noteQualifiedName = new QualifiedName("note", "http://www.w3schools.com");
            noteElementPath.AddElement(noteQualifiedName);

            // Text element path.
            textElementPath = new XmlElementPath();
            textElementPath.AddElement(noteQualifiedName);
            textElementPath.AddElement(new QualifiedName("text", "http://www.w3schools.com"));
        }
        public override void FixtureInit()
        {
            // Get note child elements.
            XmlElementPath path = new XmlElementPath();
            path.AddElement(new QualifiedName("note", "http://www.w3schools.com"));

            noteChildElements = SchemaCompletion.GetChildElementCompletion(path);

            // Get title child elements.
            path.AddElement(new QualifiedName("title", "http://www.w3schools.com"));
            titleChildElements = SchemaCompletion.GetChildElementCompletion(path);
        }
		public override void FixtureInit()
		{
			XmlElementPath path = new XmlElementPath();
			
			path.AddElement(new QualifiedName("html", "http://foo/xhtml"));
			path.AddElement(new QualifiedName("body", "http://foo/xhtml"));
			
			childElements = SchemaCompletion.GetChildElementCompletion(path);
			
			path.AddElement(new QualifiedName("p", "http://foo/xhtml"));
			paraAttributes = SchemaCompletion.GetAttributeCompletion(path);
		}
		public void ChangeNamespaceForTwoElementsWithoutNamespaceModifiesAllItems()
		{
			XmlElementPath path = new XmlElementPath();
			path.AddElement(new QualifiedName("root", String.Empty));
			path.AddElement(new QualifiedName("child", String.Empty));
			path.SetNamespaceForUnqualifiedNames("http://test");
			
			XmlElementPath expectedPath = new XmlElementPath();
			expectedPath.AddElement(new QualifiedName("root", "http://test"));
			expectedPath.AddElement(new QualifiedName("child", "http://test"));
			
			Assert.IsTrue(expectedPath.Equals(path));
		}
		public void FixtureInit()
		{
			schemaCompletion = new XmlSchemaCompletion(ResourceManager.ReadXhtmlStrictSchema());
			
			// Set up h1 element's path.
			h1Path = new XmlElementPath();
			h1Path.AddElement(new QualifiedName("html", namespaceURI));
			h1Path.AddElement(new QualifiedName("body", namespaceURI));
			h1Path.AddElement(new QualifiedName("h1", namespaceURI));
			
			// Get h1 element info.
			h1Attributes = schemaCompletion.GetAttributeCompletion(h1Path);
		}
		public void ChangeNamespaceForTwoElementsWhereChildElementHasOwnNamespaceOnlyAffectsRootElement()
		{
			XmlElementPath path = new XmlElementPath();
			path.AddElement(new QualifiedName("root", String.Empty));
			path.AddElement(new QualifiedName("child", "has-namespace-already"));
			path.SetNamespaceForUnqualifiedNames("http://test");
			
			XmlElementPath expectedPath = new XmlElementPath();
			expectedPath.AddElement(new QualifiedName("root", "http://test"));
			expectedPath.AddElement(new QualifiedName("child", "has-namespace-already"));
			
			Assert.IsTrue(expectedPath.Equals(path));
		}		
		public void GetActiveElementStartPathWithTextIncludingChildElementAttributesOnDifferentLine()
		{
			string text = "<foo xmlns='" + namespaceURI + "'>\r\n"+ 
							"<y\r\n" +
						  	"Id = 'foo' ";
	
			elementPath = XmlParser.GetActiveElementStartPath(text, text.Length);
			
			expectedElementPath = new XmlElementPath();
			expectedElementPath.AddElement(new QualifiedName("foo", namespaceURI));
			expectedElementPath.AddElement(new QualifiedName("y", namespaceURI));
			Assert.IsTrue(expectedElementPath.Equals(elementPath), 
			              "Incorrect active element path.");
		}
		public override void FixtureInit()
		{
			XmlElementPath path = new XmlElementPath();
			
			path.AddElement(new QualifiedName("project", "http://foo"));
			path.AddElement(new QualifiedName("items", "http://foo"));
			
			itemsElementChildren = SchemaCompletion.GetChildElementCompletion(path);
			
			path.AddElement(new QualifiedName("file", "http://foo"));
			
			fileElementAttributes = SchemaCompletion.GetAttributeCompletion(path);
			fileElementChildren = SchemaCompletion.GetChildElementCompletion(path);
		}
        public override void FixtureInit()
        {
            XmlElementPath path = new XmlElementPath();
            path.AddElement(new QualifiedName("group", "http://www.w3.org/2001/XMLSchema"));
            childElements = SchemaCompletion.GetChildElementCompletion(path);
            attributes = SchemaCompletion.GetAttributeCompletion(path);

            // Get annotation child elements.
            path.AddElement(new QualifiedName("annotation", "http://www.w3.org/2001/XMLSchema"));
            annotationChildElements = SchemaCompletion.GetChildElementCompletion(path);

            // Get choice child elements.
            path.Elements.RemoveLast();
            path.AddElement(new QualifiedName("choice", "http://www.w3.org/2001/XMLSchema"));
            choiceChildElements = SchemaCompletion.GetChildElementCompletion(path);
        }
        public override void FixtureInit()
        {
            XmlElementPath path = new XmlElementPath();
            path.AddElement(new QualifiedName("foo", "http://foo.com"));

            fooChildElementCompletion = SchemaCompletion.GetChildElementCompletion(path);
        }
		public void ElementPathContainsSingleRootElement()
		{
			XmlElementPath path = new XmlElementPath();
			path.AddElement(new QualifiedName("root", String.Empty));
			
			Assert.AreEqual(path, selectedElement.Path);
		}
		public override void FixtureInit()
		{			
			noteElementPath = new XmlElementPath();
			noteElementPath.AddElement(new QualifiedName("note", "http://www.w3schools.com"));

			elementCompletionItems = SchemaCompletion.GetChildElementCompletion(noteElementPath); 
		}
		public void SecondXmlElementPathHasOneElement()
		{
			XmlElementPath expectedPath = new XmlElementPath();
			expectedPath.AddElement(new QualifiedName("b", "b-namespace"));
			
			Assert.AreEqual(expectedPath, paths[1]);
		}
        public override void FixtureInit()
        {
            // Get shipto attributes.
            shipToPath = new XmlElementPath();
            QualifiedName shipOrderName = new QualifiedName("shiporder", "http://www.w3schools.com");
            shipToPath.AddElement(shipOrderName);
            shipToPath.AddElement(new QualifiedName("shipto", "http://www.w3schools.com"));

            shipToAttributes = SchemaCompletion.GetAttributeCompletion(shipToPath);

            // Get shiporder attributes.
            shipOrderPath = new XmlElementPath();
            shipOrderPath.AddElement(shipOrderName);

            shipOrderAttributes = SchemaCompletion.GetAttributeCompletion(shipOrderPath);
        }
		public override void FixtureInit()
		{
			XmlElementPath path = new XmlElementPath();
			path.AddElement(new QualifiedName("foo", "http://foo.com"));
			
			attributeCompletionItems = SchemaCompletion.GetAttributeCompletion(path);
		}
		public void NoAttributesForUnknownElement()
		{
			XmlElementPath path = new XmlElementPath();
			path.AddElement(new QualifiedName("foobar", "http://www.w3schools.com"));
			XmlCompletionItemCollection attributes = SchemaCompletion.GetAttributeCompletion(path);
			
			Assert.AreEqual(0, attributes.Count, "Should not find attributes for unknown element.");
		}
Esempio n. 31
0
        /// <summary>
        /// Gets the parent element path based on the index position. This
        /// method does not compact the path so it will include all elements
        /// including those in another namespace in the path.
        /// </summary>
        static XmlElementPath GetFullParentElementPath(string xml)
        {
            XmlElementPath path = new XmlElementPath();
            IDictionary <string, string> namespacesInScope = null;

            using (StringReader reader = new StringReader(xml)) {
                using (XmlTextReader xmlReader = new XmlTextReader(reader)) {
                    try {
                        xmlReader.XmlResolver = null;                         // prevent XmlTextReader from loading external DTDs
                        while (xmlReader.Read())
                        {
                            switch (xmlReader.NodeType)
                            {
                            case XmlNodeType.Element:
                                if (!xmlReader.IsEmptyElement)
                                {
                                    QualifiedName elementName = new QualifiedName(xmlReader.LocalName, xmlReader.NamespaceURI, xmlReader.Prefix);
                                    path.AddElement(elementName);
                                }
                                break;

                            case XmlNodeType.EndElement:
                                path.Elements.RemoveLast();
                                break;
                            }
                        }
                    } catch (XmlException) {
                        namespacesInScope = xmlReader.GetNamespacesInScope(XmlNamespaceScope.All);
                    }
                }
            }

            // Add namespaces in scope for the last element read.
            if (namespacesInScope != null)
            {
                foreach (KeyValuePair <string, string> ns in namespacesInScope)
                {
                    path.NamespacesInScope.Add(new XmlNamespace(ns.Key, ns.Value));
                }
            }

            return(path);
        }