Package nu.xom

Examples of nu.xom.Element.addNamespaceDeclaration()


    public void testExclusiveDoesntRenderUnusedPrefix()
      throws IOException {
    
        Element pdu = new Element("n0:tuck", "http://a.example");
        pdu.addNamespaceDeclaration("pre", "http://www.example.org/");
  
        String expected = "<n0:tuck xmlns:n0=\"http://a.example\"></n0:tuck>";
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        Canonicalizer canonicalizer = new Canonicalizer(out,
          Canonicalizer.EXCLUSIVE_XML_CANONICALIZATION_WITH_COMMENTS);
View Full Code Here


      {
       
        String name = "red:sakjdhjhd";
        String uri = "http://www.red.com/";
        Element e = new Element(name, uri);
        e.addNamespaceDeclaration("red", "http://www.red.com/");
       
        try {
            e.setNamespaceURI("http://www.example.com");
            fail("illegal namespace conflict")
        }
View Full Code Here

    public void testChangePrefix() {
       
        String name = "red:sakjdhjhd";
        String uri = "http://www.red.com/";
        Element element = new Element(name, uri);
        element.addNamespaceDeclaration("blue", "http://www.foo.com/");
        element.addAttribute(new Attribute("green:money",
         "http://example.com/", "value"));
        element.addNamespaceDeclaration("purple", uri);
        element.addAttribute(
          new Attribute("mauve:money", uri, "value"));
View Full Code Here

        String uri = "http://www.red.com/";
        Element element = new Element(name, uri);
        element.addNamespaceDeclaration("blue", "http://www.foo.com/");
        element.addAttribute(new Attribute("green:money",
         "http://example.com/", "value"));
        element.addNamespaceDeclaration("purple", uri);
        element.addAttribute(
          new Attribute("mauve:money", uri, "value"));
       
        try {
            element.setNamespacePrefix("blue");
View Full Code Here

        String uri = "http://www.red.com/";
        Element e = new Element(name, uri);

        for (int i = 0; i < legal.length; i++) {
            e.removeNamespaceDeclaration("prefix");         
            e.addNamespaceDeclaration("prefix", legal[i]);         
            assertEquals(legal[i], e.getNamespaceURI("prefix"));
        }
       
        for (int i = 0; i < illegal.length; i++) {
            try {
View Full Code Here

            assertEquals(legal[i], e.getNamespaceURI("prefix"));
        }
       
        for (int i = 0; i < illegal.length; i++) {
            try {
                e.addNamespaceDeclaration("prefix", illegal[i]);         
                fail("illegal namespace URI allowed " + illegal[i])
            }
            catch (MalformedURIException ex) {
            // success  
            assertNotNull(ex.getMessage());
View Full Code Here


    public void testAddAttributesWithAdditionalNamespaces() {
       
        Element element = new Element("name");
        element.addNamespaceDeclaration(
          "xlink", "http://www.w3.org/TR/1999/xlink");
        element.addNamespaceDeclaration(
          "pre", "http://www.example.com");
       
       
View Full Code Here

    public void testAddAttributesWithAdditionalNamespaces() {
       
        Element element = new Element("name");
        element.addNamespaceDeclaration(
          "xlink", "http://www.w3.org/TR/1999/xlink");
        element.addNamespaceDeclaration(
          "pre", "http://www.example.com");
       
       
        Attribute a1 = new Attribute("name", "value");
        Attribute a2 = new Attribute("xlink:type",
View Full Code Here

          new Attribute("ok:att", "ftp://example.com/", "value")
        );
        assertEquals(3, element.getAttributeCount());

        try {
            element.addNamespaceDeclaration(
              "ok", "http://www.example.net");
            fail("added namespace declaration that " +
                "conflicts with attribute");
        }
        catch (NamespaceConflictException ex) {
View Full Code Here

  
    public void testCopyConstructorWithAdditionalNamespaces() {
       
        Element original = new Element("red");
        original.addNamespaceDeclaration("pre", "http://www.example.org");
        Element copy = new Element(original);
        assertEquals("http://www.example.org", copy.getNamespaceURI("pre"));
       
    }
   
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.