Example usage for org.dom4j DocumentHelper createDocument

List of usage examples for org.dom4j DocumentHelper createDocument

Introduction

In this page you can find the example usage for org.dom4j DocumentHelper createDocument.

Prototype

public static Document createDocument() 

Source Link

Usage

From source file:org.etudes.api.app.melete.util.XMLHelper.java

License:Apache License

/**
 * creates xml file for the give path//w w w  .  jav a 2s .c  o  m
 * @param url - path to create xml file
 * @throws IOException
 */
static public void generateXMLFile(String url, Document document) throws Exception {
    XMLWriter writer = null;
    FileOutputStream out = null;
    try {
        if (document == null)
            document = DocumentHelper.createDocument();

        out = new FileOutputStream(new File(url));
        OutputFormat outformat = OutputFormat.createPrettyPrint();
        //outformat.setEncoding(aEncodingScheme);
        writer = new XMLWriter(out, outformat);
        writer.write(document);
        writer.flush();
    } catch (IOException e1) {
        throw e1;
    } catch (Exception e) {
        throw e;
    } finally {
        try {
            if (writer != null)
                writer.close();
        } catch (IOException e2) {
        }

        try {
            if (out != null)
                out.close();
        } catch (IOException e3) {
        }
    }
}

From source file:org.etudes.component.app.melete.MeleteSecurityServiceImpl.java

License:Apache License

private String createdom4jtree(org.dom4j.Element oneelement) {
    org.dom4j.Document document4jmelete = DocumentHelper.createDocument();
    org.dom4j.Element document4jmeleteRoot = document4jmelete.getRootElement();
    org.dom4j.Element organizationNewElement = oneelement.createCopy();
    organizationNewElement.setParent(document4jmeleteRoot);
    document4jmelete.add(organizationNewElement);
    return document4jmelete.asXML();
}

From source file:org.etudes.component.app.melete.SubSectionUtilImpl.java

License:Apache License

private void createInitialModule() {
    subSection4jDOM = DocumentHelper.createDocument();
    subSection4jDOM.addDocType("module", "", "");
    setInternalDTD();/*from  ww  w. ja v a 2 s.c o  m*/
    Element root = subSection4jDOM.addElement("module");
    subSection4jDOM.setRootElement(root);
}

From source file:org.forzaframework.util.XmlUtils.java

License:Apache License

public static Document buildEmptyListDocument() {
    Document doc = DocumentHelper.createDocument();
    doc.setXMLEncoding("ISO-8859-1");
    buildEmptyListDocument(doc);/*from   ww  w  . ja  v a2  s.co m*/
    return doc;
}

From source file:org.forzaframework.util.XmlUtils.java

License:Apache License

public static Document buildDocument(List<? extends BaseEntity> list) {
    Document doc = DocumentHelper.createDocument();
    doc.setXMLEncoding("ISO-8859-1");
    buildDocument(doc, list, list.size());
    return doc;/*from   ww  w. ja  v  a2  s . c  om*/
}

From source file:org.forzaframework.util.XmlUtils.java

License:Apache License

public static Document buildDocument(List<? extends BaseEntity> list, Integer totalCount) {
    Document doc = DocumentHelper.createDocument();
    doc.setXMLEncoding("ISO-8859-1");
    buildDocument(doc, list, totalCount);
    return doc;/*from ww w  . j  ava2s . co  m*/
}

From source file:org.forzaframework.util.XmlUtils.java

License:Apache License

public static Document buildDocument(List list, String[] elements) throws Exception {
    Document doc = DocumentHelper.createDocument();
    buildDocument(doc, list, list.size(), elements);
    return doc;/*ww w.ja v  a  2s. c  o m*/
}

From source file:org.forzaframework.util.XmlUtils.java

License:Apache License

public static Document buildDocument(List list, List<String> elements) throws Exception {
    Document doc = DocumentHelper.createDocument();
    buildDocument(doc, list, list.size(), elements.toArray(new String[elements.size()]));
    return doc;/* w  w w  . j a v a  2  s  .c  om*/
}

From source file:org.forzaframework.util.XmlUtils.java

License:Apache License

/**
 * Arma un Xml con la informacion de la lista
 *
 * @param list          Lista de objetos
 * @param elements    Map en donde Key = Nombre que tendra el elemento y Value = propiedad de la clase de donde se obtendra el valor para ese elemento
 * @return              Document//from ww  w.j a va2  s  . co  m
 * @throws Exception
 */
public static Document buildDocument(List list, Map<String, String> elements) throws Exception {
    Document doc = DocumentHelper.createDocument();
    doc.setXMLEncoding("ISO-8859-1");
    buildDocument(doc, list, list.size(), elements, null);

    return doc;
}

From source file:org.forzaframework.util.XmlUtils.java

License:Apache License

public static Document buildDocument(List list, Integer size, String[] elements) throws Exception {
    Document doc = DocumentHelper.createDocument();
    doc.setXMLEncoding("ISO-8859-1");
    buildDocument(doc, list, size, elements);
    return doc;/*  www  .jav  a2 s.  c  o m*/
}