Ejemplo n.º 1
0
        public void singleAttribute()
        {
            XPathContext ctx = new XPathContext();

            ctx.SetChildren(Linqy.Singleton(new Element("foo")));
            ctx.NavigateToChild(0);
            ctx.AddAttribute(new XmlQualifiedName("bar"));
            ctx.NavigateToAttribute(new XmlQualifiedName("bar"));
            Assert.AreEqual("/foo[1]/@bar", ctx.XPath);
            Assert.AreEqual("/foo[1]", ctx.ParentXPath);
        }
Ejemplo n.º 2
0
        public void AttributesAndNs()
        {
            Dictionary <string, string> m = new Dictionary <string, string>();

            m["bar"] = "urn:foo:bar";
            XPathContext ctx = new XPathContext(m);

            ctx.SetChildren(Linqy.Singleton(new Element("foo",
                                                        "urn:foo:bar")));
            ctx.NavigateToChild(0);
            List <XmlQualifiedName> l = new List <XmlQualifiedName>();

            l.Add(new XmlQualifiedName("baz"));
            l.Add(new XmlQualifiedName("baz", "urn:foo:bar"));
            ctx.AddAttributes(l);
            ctx.NavigateToAttribute(new XmlQualifiedName("baz"));
            Assert.AreEqual("/bar:foo[1]/@baz", ctx.XPath);
            Assert.AreEqual("/bar:foo[1]", ctx.ParentXPath);
            ctx.NavigateToParent();
            ctx.NavigateToAttribute(new XmlQualifiedName("baz", "urn:foo:bar"));
            Assert.AreEqual("/bar:foo[1]/@bar:baz", ctx.XPath);
            Assert.AreEqual("/bar:foo[1]", ctx.ParentXPath);
            ctx.NavigateToParent();
        }