Package nu.xom

Examples of nu.xom.Attribute


    // JAXEN-46: http://jira.codehaus.org/browse/JAXEN-46
    public void testHashInAttributeValue() {
       
        Element root = new Element("test");
        Document doc = new Document(root);
        Attribute test = new Attribute("test", "SUBSCRIBER");
        Attribute test1 = new Attribute("test1", "SUBSCRIBER#");
        root.addAttribute(test);
        root.addAttribute(test1);
       
        Nodes result = doc.query("test[@test='SUBSCRIBER']");
        assertEquals(1, result.size());
View Full Code Here


    public void testStartsWith() {
       
        Element parent = new Element("Test");
        Element child = new Element("child");
        child.addAttribute(new Attribute("foo", "bar"));
        parent.appendChild(child);
        Element child2 = new Element("child");
        child2.addAttribute(new Attribute("foo", "big"));
        parent.appendChild(child2);
       
        Nodes result = parent.query(".//*[starts-with(@foo, 'ba')]");
        assertEquals(1, result.size());
        assertEquals(child, result.get(0));
View Full Code Here

    // a jaxen extension function
    public void testEndsWith() {
       
        Element parent = new Element("Test");
        Element child = new Element("child");
        child.addAttribute(new Attribute("foo", "bar"));
        parent.appendChild(child);
       
        try {
            parent.query(".//*[ends-with(@foo, 'ar')]");
            fail("Allowed Jaxen extension function");
View Full Code Here

    public void testXMLLang() {
       
        Element parent = new Element("Test");
        Element child1 = new Element("child");
        child1.addAttribute(new Attribute("xml:lang",
          "http://www.w3.org/XML/1998/namespace", "en"));
        parent.appendChild(child1);
        Element child2 = new Element("child");
        child2.appendChild("2");
        child2.addAttribute(new Attribute("xml:lang",
          "http://www.w3.org/XML/1998/namespace", "fr"));
        parent.appendChild(child2);
        Element child3 = new Element("child");
        child3.appendChild("3");
        parent.appendChild(child3);
        Element child4 = new Element("child");
        child4.appendChild("4");
        child4.addAttribute(new Attribute("xml:lang",
          "http://www.w3.org/XML/1998/namespace", "en-US"));
        parent.appendChild(child4);
       
        Nodes result = parent.query("child::*[lang('en')]");
        assertEquals(2, result.size());
View Full Code Here

    public void testXMLPrefixIsAlwaysBound() {
       
        Element parent = new Element("Test");
        Element child1 = new Element("child");
        child1.addAttribute(new Attribute("xml:lang",
          "http://www.w3.org/XML/1998/namespace", "en"));
        parent.appendChild(child1);
        Element child2 = new Element("child");
        child2.appendChild("2");
        child2.addAttribute(new Attribute("xml:lang",
          "http://www.w3.org/XML/1998/namespace", "fr"));
        parent.appendChild(child2);
        Element child3 = new Element("child");
        child3.appendChild("3");
        parent.appendChild(child3);
        Element child4 = new Element("child");
        child4.appendChild("4");
        child4.addAttribute(new Attribute("xml:lang",
          "http://www.w3.org/XML/1998/namespace", "en-US"));
        parent.appendChild(child4);
       
        Nodes result = parent.query("child::*/@xml:lang");
        assertEquals(3, result.size());  
View Full Code Here

    public void testGetAttributeQName() {
       
        Element grandparent = new Element("Test");
        Document doc = new Document(grandparent);
        Element parent = new Element("Test");
        Attribute a1 = new Attribute("pre:attribute", "http://www.example.org/", "test");
        Attribute a2 = new Attribute("pre:attribute", "http://www.example.com/", "test");
        parent.addAttribute(a2);
        grandparent.addAttribute(a1);
        grandparent.appendChild(parent);
       
        Nodes result = doc.query("descendant::*/attribute::*[name(.)='pre:attribute']");
 
View Full Code Here

    }
   
    public void testSelfAxisWithAttribute() {
       
        Element e = new Element("child");
        e.addAttribute(new Attribute("test", "value"));
        Nodes result = e.query("@*[self::test]");
        assertEquals(0, result.size());
       
    }
View Full Code Here

    public void testAttributeAxis() {
       
        Element parent = new Element("Test");
        Element child = new Element("child");
        parent.appendChild(child);
        parent.addAttribute(new Attribute("name", "value"));
        parent.addAttribute(new Attribute("name2", "value"));
       
        Nodes result = child.query("attribute::*");
        assertEquals(0, result.size());
        result = parent.query("attribute::*");
        assertEquals(2, result.size());
View Full Code Here

        Element child2 = new Element("child2");
        Element child3 = new Element("child3");
        parent.appendChild(child1);
        parent.appendChild(child2);
        parent.appendChild(child3);
        Attribute a1 = new Attribute("a1", "value");
        Attribute a2 = new Attribute("a2", "value");
        Attribute a3 = new Attribute("a3", "value");
        child2.addAttribute(a1);
        child2.addAttribute(a2);
        child2.addAttribute(a3);
       
        Nodes result = a2.query("preceding-sibling::node()");
View Full Code Here

       
        Element parent = new Element("Test");
        Element child1 = new Element("child1");
        Element child2 = new Element("child2");
        Element child3 = new Element("child3");
        Attribute id = new Attribute("a", "anchor");
        id.setType(Attribute.Type.ID);
        child2.addAttribute(id);
       
        parent.appendChild(child1);
        parent.appendChild(child2);
        parent.appendChild(child3);
View Full Code Here

TOP

Related Classes of nu.xom.Attribute

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.