Package org.jdom2

Examples of org.jdom2.Element.addNamespaceDeclaration()


  public void testOutputElementNamespaces() {
    String txt = "<ns:root xmlns:ns=\"myns\" xmlns:ans=\"attributens\" xmlns:two=\"two\" ans:att=\"val\"/>";
    Element emt = new Element("root", Namespace.getNamespace("ns", "myns"));
    Namespace ans = Namespace.getNamespace("ans", "attributens");
    emt.setAttribute(new Attribute("att", "val", ans));
    emt.addNamespaceDeclaration(Namespace.getNamespace("two", "two"));
    checkOutput(emt,
        txt, txt,txt, txt, txt);
  }

  @Test
View Full Code Here


   
    @Test
    public void testOutputDocumentNamespaces() {
    Element emt = new Element("root", Namespace.getNamespace("ns", "myns"));
    Namespace ans = Namespace.getNamespace("ans", "attributens");
    emt.addNamespaceDeclaration(ans);
    emt.addNamespaceDeclaration(Namespace.getNamespace("two", "two"));
    emt.setAttribute(new Attribute("att", "val", ans));
    emt.addContent(new Element("child", Namespace.getNamespace("", "childuri")));
    Document doc = new Document(emt);
    roundTripDocument(doc);
View Full Code Here

    @Test
    public void testOutputDocumentNamespaces() {
    Element emt = new Element("root", Namespace.getNamespace("ns", "myns"));
    Namespace ans = Namespace.getNamespace("ans", "attributens");
    emt.addNamespaceDeclaration(ans);
    emt.addNamespaceDeclaration(Namespace.getNamespace("two", "two"));
    emt.setAttribute(new Attribute("att", "val", ans));
    emt.addContent(new Element("child", Namespace.getNamespace("", "childuri")));
    Document doc = new Document(emt);
    roundTripDocument(doc);
    }
View Full Code Here

   
    @Test
    public void testRTOutputElementNamespaces() {
    Element emt = new Element("root", Namespace.getNamespace("ns", "myns"));
    Namespace ans = Namespace.getNamespace("ans", "attributens");
    emt.addNamespaceDeclaration(ans);
    emt.addNamespaceDeclaration(Namespace.getNamespace("two", "two"));
    emt.setAttribute(new Attribute("att", "val", ans));
    emt.addContent(new Element("child", Namespace.getNamespace("", "childns")));
    roundTripElement(emt);
    }
View Full Code Here

    @Test
    public void testRTOutputElementNamespaces() {
    Element emt = new Element("root", Namespace.getNamespace("ns", "myns"));
    Namespace ans = Namespace.getNamespace("ans", "attributens");
    emt.addNamespaceDeclaration(ans);
    emt.addNamespaceDeclaration(Namespace.getNamespace("two", "two"));
    emt.setAttribute(new Attribute("att", "val", ans));
    emt.addContent(new Element("child", Namespace.getNamespace("", "childns")));
    roundTripElement(emt);
    }
   
View Full Code Here

    for (final Iterator<?> it = event.getNamespaces(); it.hasNext();) {
      final javax.xml.stream.events.Namespace ns =
          (javax.xml.stream.events.Namespace)it.next();

      element.addNamespaceDeclaration(Namespace.getNamespace(
          ns.getPrefix(), ns.getNamespaceURI()));
    }

    return element;
  }
View Full Code Here

              reader.getAttributeNamespace(i))));
    }

    // Handle Namespaces
    for (int i = 0, len = reader.getNamespaceCount(); i < len; i++) {
      element.addNamespaceDeclaration(Namespace.getNamespace(
          reader.getNamespacePrefix(i), reader.getNamespaceURI(i)));
    }

    return element;
  }
View Full Code Here

        }

        // Only add namespaces to non-embedded resources
        if (!embedded) {
            for (Map.Entry<String, String> entry : representation.getNamespaces().entrySet()) {
                resourceElement.addNamespaceDeclaration(
                        Namespace.getNamespace(entry.getKey(), entry.getValue()));
            }
            // Add the instance namespace if there are null properties on this
            // representation or on any embedded resources.
            if (representation.hasNullProperties()) {
View Full Code Here

                        Namespace.getNamespace(entry.getKey(), entry.getValue()));
            }
            // Add the instance namespace if there are null properties on this
            // representation or on any embedded resources.
            if (representation.hasNullProperties()) {
                resourceElement.addNamespaceDeclaration(XSI_NAMESPACE);
            }
        }

        //add a comment
//        resourceElement.addContent(new Comment("Description of a representation"));
View Full Code Here

    protected Element createRootElement(Channel channel) {
        Element root = new Element("rss",getFeedNamespace());
        Attribute version = new Attribute("version", getVersion());
        root.setAttribute(version);
        root.addNamespaceDeclaration(getContentNamespace());
        generateModuleNamespaceDefs(root);
        return root;
    }

    protected void populateFeed(Channel channel,Element parent) throws FeedException  {
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.