protected Element createElement(String name, XMLNamespace ns) {
   Element elem = new Element(name, ns.getUri());
   if (!LAKEVIEW.equals(ns)) {
     elem.setNamespacePrefix(ns.getPrefix());
   }
   return elem;
 }
Exemplo n.º 2
0
 public static void xom() {
   // XOM dynamically enforces presence, non-nullness & non-emptyness of URI if prefix is given
   nu.xom.Element root = new nu.xom.Element("todo");
   try {
     root.setNamespacePrefix("todo");
   } catch (nu.xom.NamespaceConflictException e) {
     System.out.println("XOM:");
     System.out.println(e.getMessage());
   }
 }
Exemplo n.º 3
0
  public static void xomWithURI() {
    nu.xom.Element root = new nu.xom.Element("todo");

    // Setting URI and prefix has the consequence that the namespace declaration is added
    root.setNamespaceURI("http://www.example.com");
    root.setNamespacePrefix("todo");
    //		System.out.println(root.getAttributeCount()); // prints 0 xmlns etc. are no attributes.
    nu.xom.Document doc = new nu.xom.Document(root);
    System.out.println("XOM:");
    System.out.println(doc.toXML());
  }