Package org.dom4j

Examples of org.dom4j.Document.addElement()


   * @return DOM document
   */
  private Document exportUsers() {
    Document document = DocumentHelper.createDocument();

    Element root = document.addElement("server-data",
        "http://www.xmpp.org/extensions/xep-0227.html#ns");

    Element host = root.addElement("host");

    host.addAttribute("jid", serverName);
View Full Code Here


        } else {
          result = query.fetch();
        }
       
        Document response = DocumentHelper.createDocument();
        Element r = response.addElement("result");
        for (Model obj : result) {
          Element object = r.addElement("object");
          fillRequestElement(obj, object, false);
        }
        // TODO add nextOffset to response
View Full Code Here

    return response;
  }
 
  private Document error(Throwable e) {
    Document response = DocumentHelper.createDocument();
    Element root = response.addElement("error");
    root.addAttribute("class", e.getClass().getName());
    root.setText(e.getMessage());
    return response;
  }
 
View Full Code Here

 
  private static Document fromJson(Json json) {
    String root = json.keys().iterator().next();
   
    Document doc = DocumentHelper.createDocument();
    fromJson(json.get(root), doc.addElement(root));
    return doc;
  }
 
  private static void fromJson(Json json, Element element) {
    Set<String> keys = json.keys();
View Full Code Here

    }
  }
 
  public static void main(String[] args) {
    Document doc = DocumentHelper.createDocument();
    doc.addElement("root")
      .addAttribute("foo", "bar")
      .addAttribute("foobar", "baz")
      .addElement("child")
      .addAttribute("x", "y")
      .addElement("grandchild")
View Full Code Here

    simpleRequest("update", obj, false);
  }
 
  protected Document createRequest(String name) {
    Document d = DocumentHelper.createDocument();
    Element root = d.addElement(name);
    if(key != null) {
      String time = Long.toString(System.currentTimeMillis());
      root.addAttribute("time", time);
      root.addAttribute("hash", Util.sha1(time+key));
    }
View Full Code Here

    XmlSerializer serializer = new XmlSerializer();
   
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
   
    Document document = DocumentHelper.createDocument();
    document.addElement("root");
    serializer.serialize(document, baos);
   
    Document result = serializer.deserialize(new ByteArrayInputStream(baos.toByteArray()));
   
    assertEquals(result.getRootElement().getName(),
View Full Code Here

        return new SchemaColumn( columnId, columnName, dbType, javaType, index );
    }

    private void buildSchema( ResultSet columns, InputStream schemaFile, String className, String tableName, Field[] fields ) {
        Document document = DocumentHelper.createDocument();
        Element root = document.addElement( "table" );
        root.addAttribute( "name", tableName );
        root.addAttribute( "className", className );
        XMLWriter writer;
        Element field;
        HashMap<String, Field> fieldMap = new HashMap<String, Field>();
View Full Code Here

  public boolean save(OutputStream outStream) {
    Document xmlOutDoc = DocumentHelper.createDocument();

    // Building namespace
    Namespace dfNs = Namespace.get("", TYPES_NAMESPACE_URI);
    Element typesElem = xmlOutDoc
        .addElement(new QName(TYPES_TAG_NAME, dfNs));

    // Adding default types
    for (Entry<String, String> entry : defaultContentType.entrySet()) {
      appendDefaultType(typesElem, entry);
View Full Code Here

    // Building xml
    Document xmlOutDoc = DocumentHelper.createDocument();
    // make something like <Relationships
    // xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
    Namespace dfNs = Namespace.get("", PackageNamespaces.RELATIONSHIPS);
    Element root = xmlOutDoc.addElement(new QName(
        PackageRelationship.RELATIONSHIPS_TAG_NAME, dfNs));

    // <Relationship
    // TargetMode="External"
    // Id="rIdx"
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.