Package nu.xom

Examples of nu.xom.Element.addNamespaceDeclaration()


    public void testPredicateWithNamespaceAxis() {
       
        Element parent = new Element("Test");
        Element child = new Element("child", "http://www.example.com");
        Element grandchild = new Element("child", "http://www.example.com");
        grandchild.addNamespaceDeclaration("pre", "http://www.w3.org/");
        parent.appendChild(child);
        child.appendChild(grandchild);
       
        // Every node has at least a mapping for xml prefix.
        Nodes result = parent.query("self::*[count(namespace::*)=0]");
 
View Full Code Here


    public void testPredicateWithNamespaceAxis2() {
       
        Element parent = new Element("Test");
        Element child = new Element("child", "http://www.example.com");
        Element grandchild = new Element("child", "http://www.example.com");
        grandchild.addNamespaceDeclaration("pre", "http://www.w3.org/");
        parent.appendChild(child);
        child.appendChild(grandchild);
       
        // Every node has at least a mapping for xml prefix.
        Nodes result = parent.query("*[count(namespace::*)=0]");
 
View Full Code Here

        Element parent = new Element("Test", "http://www.example.org");
        Element child = new Element("child", "http://www.example.org");
        parent.appendChild(child);
       
        Element test = new Element("test");
        test.addNamespaceDeclaration("pre", "http://www.example.org");
        XPathContext context = XPathContext.makeNamespaceContext(test);
        Nodes result = parent.query("child::pre:child", context);
        assertEquals(1, result.size());
        assertEquals(child, result.get(0));  
       
View Full Code Here

        Element parent = new Element("Test", "http://www.example.org");
        Element child = new Element("child", "http://www.example.org");
        parent.appendChild(child);
       
        Element test = new Element("test");
        test.addNamespaceDeclaration("pre", "http://www.example.org");
        Element testChild = new Element("testchild");
        test.appendChild(testChild);
        XPathContext context = XPathContext.makeNamespaceContext(testChild);
        Nodes result = parent.query("child::pre:child", context);
        assertEquals(1, result.size());
View Full Code Here

   
    public void testAdditionalNamespace() 
      throws IOException, SAXException, ParsingException {
       
        Element root = new Element("root");
        root.addNamespaceDeclaration("xsl", "http://www.w3.org/1999/XSL/Transform");
        Document doc = new Document(root)
        convertAndCompare(doc);
       
    }
   
View Full Code Here

   
    public void testPrefixAndAdditionalNamespace() 
      throws IOException, SAXException, ParsingException {
       
        Element root = new Element("xsl:root", "http://www.w3.org/1999/XSL/Transform");
        root.addNamespaceDeclaration("xsl", "http://www.w3.org/1999/XSL/Transform");
        Document doc = new Document(root)
        convertAndCompare(doc);
       
    }
   
View Full Code Here

   
   
    public void testAdditionalNamespaceDuplicatesElementNamespace() {
       
        Element element = new Element("pre:element", "http://www.example.org");
        element.addNamespaceDeclaration("pre", "http://www.example.org");
        element.setNamespacePrefix("foo");
        assertEquals("http://www.example.org", element.getNamespaceURI("pre"));
       
    }
   
View Full Code Here

          "http://www.w3.org/2001/xlink", "value"));
        assertEquals(2, test.getNamespaceDeclarationCount());
        test.addAttribute(new Attribute("xlink:href",
          "http://www.w3.org/2001/xlink", "value"));
        assertEquals(2, test.getNamespaceDeclarationCount());
        test.addNamespaceDeclaration("xlink", "http://www.w3.org/2001/xlink");
        assertEquals(2, test.getNamespaceDeclarationCount());
        test.addNamespaceDeclaration("xsi", "http://www.w3.org/2001/xmlschema-instance");
        assertEquals(3, test.getNamespaceDeclarationCount());
          
    }
View Full Code Here

        test.addAttribute(new Attribute("xlink:href",
          "http://www.w3.org/2001/xlink", "value"));
        assertEquals(2, test.getNamespaceDeclarationCount());
        test.addNamespaceDeclaration("xlink", "http://www.w3.org/2001/xlink");
        assertEquals(2, test.getNamespaceDeclarationCount());
        test.addNamespaceDeclaration("xsi", "http://www.w3.org/2001/xmlschema-instance");
        assertEquals(3, test.getNamespaceDeclarationCount());
          
    }

View Full Code Here

    public void testAddSameNamespaceDeclaration() {
       
        Element e = new Element("test", "http://www.example.com");
      
        try {
            e.addNamespaceDeclaration("", "http://www.red.com");
            fail("added conflicting default namespace");  
        }
        catch (NamespaceConflictException success) {
            assertNotNull(success.getMessage());
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.