Example usage for org.dom4j Element addAttribute

List of usage examples for org.dom4j Element addAttribute

Introduction

In this page you can find the example usage for org.dom4j Element addAttribute.

Prototype

Element addAttribute(QName qName, String value);

Source Link

Document

Adds the attribute value of the given fully qualified name.

Usage

From source file:com.haulmont.yarg.structure.xml.impl.DefaultXmlWriter.java

License:Apache License

protected void writeTemplates(Report report, Element root) {
    Map<String, ReportTemplate> reportTemplates = report.getReportTemplates();
    Element reportTemplatesElement = root.addElement("templates");
    for (ReportTemplate reportTemplate : reportTemplates.values()) {
        Element reportTemplateElement = reportTemplatesElement.addElement("template");
        reportTemplateElement.addAttribute("code", reportTemplate.getCode());
        reportTemplateElement.addAttribute("documentName", reportTemplate.getDocumentName());
        reportTemplateElement.addAttribute("documentPath", reportTemplate.getDocumentPath());
        reportTemplateElement.addAttribute("outputType", reportTemplate.getOutputType().getId());
        reportTemplateElement.addAttribute("outputNamePattern", reportTemplate.getOutputNamePattern());
    }/*from   ww  w.j  a  va2 s.  co m*/
}

From source file:com.haulmont.yarg.structure.xml.impl.DefaultXmlWriter.java

License:Apache License

protected void writeBandDefinition(Element element, ReportBand bandDefinition) {
    element.addAttribute("name", bandDefinition.getName());
    element.addAttribute("orientation", bandDefinition.getBandOrientation().id);
    Element childrenBandsElement = element.addElement("bands");

    Element reportQueriesElement = element.addElement("queries");
    if (bandDefinition.getReportQueries() != null) {
        for (ReportQuery reportQuery : bandDefinition.getReportQueries()) {
            Element reportQueryElement = reportQueriesElement.addElement("query");
            reportQueryElement.addAttribute("name", reportQuery.getName());
            reportQueryElement.addAttribute("type", reportQuery.getLoaderType());
            reportQueryElement.addElement("script").setText(reportQuery.getScript());
        }/*from   www.  j  av  a 2 s.  com*/
    }

    if (bandDefinition.getChildren() != null) {
        for (ReportBand childBandDefinition : bandDefinition.getChildren()) {
            Element childBandElement = childrenBandsElement.addElement("band");
            writeBandDefinition(childBandElement, childBandDefinition);
        }
    }
}

From source file:com.hazzard.gui.PiNet.java

public void sendCommand(String command, String data) throws Exception {
    Document document;/*w  ww  . ja  va2  s .com*/
    document = DocumentHelper.createDocument();
    Element root = document.addElement("commands");
    Element commandElem = root.addElement("command");
    commandElem.setText(command);

    commandElem.addAttribute("data", data);

    final Writer writer = new StringWriter();
    new XMLWriter(writer).write(root);
    String text = writer.toString().trim();

    DatagramPacket pack = new DatagramPacket(text.getBytes(), text.length(), InetAddress.getByName(group),
            port);
    sock_send.send(pack);
}

From source file:com.hihframework.osplugins.dom4j.XmlParseUtil.java

License:Apache License

/**
 * ?//from w  w w  .  j  av  a  2s . com
 *
 * @param element???
 * @param attributeName???
 * @param attributeValue?
 */
public void addAttribute(Element element, String attributeName, String attributeValue) {
    element.addAttribute(attributeName, attributeValue);
}

From source file:com.ibm.cognos.API.java

License:Open Source License

public API() {
    Element reportElement = DocumentHelper.createElement("report");

    // In dom4j 1.6.1, can no longer add xmlns with addAttribute
    reportElement.addNamespace("", "http://developer.cognos.com/schemas/report/8.0/");
    reportElement.addAttribute("expressionLocale", "en-us");
    oDocument = DocumentHelper.createDocument(reportElement);
}

From source file:com.ibm.cognos.API.java

License:Open Source License

public void addPage(String p_sName) {
    Element n = (Element) oDocument.selectSingleNode("/report/layouts/layout/reportPages");
    if (n == null) {
        addReportPages();// w w w. j av  a 2  s . c  o m
        n = (Element) oDocument.selectSingleNode("/report/layouts/layout/reportPages");
    }

    Element e = DocumentHelper.createElement("page");
    Element eStyle = buildStyle("pg");

    e.addAttribute("name", p_sName);
    e.add(eStyle);
    n.add(e);
}

From source file:com.ibm.cognos.API.java

License:Open Source License

public void addList(String p_sName) {
    Element n = (Element) oDocument
            .selectSingleNode("/report/layouts/layout/reportPages/page/pageBody/contents");
    if (n == null) {
        addPageBodyContents();/*from  w w  w.  j a v a 2 s.c om*/
        n = (Element) oDocument.selectSingleNode("/report/layouts/layout/reportPages/page/pageBody/contents");
    }

    Element e = DocumentHelper.createElement("list");

    Element eStyle = buildStyle("ls");

    e.addAttribute("refQuery", p_sName);
    e.add(eStyle);

    n.add(e);
}

From source file:com.ibm.cognos.API.java

License:Open Source License

public void addCSS(String p_sName) {
    Element n = (Element) oDocument
            .selectSingleNode("/report/layouts/layout/reportPages/page/pageBody/contents/list/style");
    if (n == null) {
        addStyle();//from   www .j a  va 2  s  . c  o  m
        n = (Element) oDocument
                .selectSingleNode("/report/layouts/layout/reportPages/page/pageBody/contents/list/style");
    }

    Element e = DocumentHelper.createElement("CSS");
    e.addAttribute("value", p_sName);
    n.add(e);
}

From source file:com.ibm.cognos.API.java

License:Open Source License

public Element buildStyle(String sName) {
    Element eStyle = DocumentHelper.createElement("style");
    Element eDefaultStyles = DocumentHelper.createElement("defaultStyles");
    Element eDefinedStyle = DocumentHelper.createElement("defaultStyle");
    eDefinedStyle.addAttribute("refStyle", sName);

    eDefaultStyles.add(eDefinedStyle);/*  ww w  .  j  a  va  2 s  .  c  o  m*/
    eStyle.add(eDefaultStyles);

    return eStyle;
}

From source file:com.ibm.cognos.API.java

License:Open Source License

public void addQuery(String p_sName) {
    Element n = (Element) oDocument.selectSingleNode("/report/queries");
    if (n == null) {
        addQueries();/* w  ww  .j  a  v a  2s .  c  om*/
        n = (Element) oDocument.selectSingleNode("/report/queries");
    }

    Element eModel = DocumentHelper.createElement("model");
    Element eSource = DocumentHelper.createElement("source");

    Element e = DocumentHelper.createElement("query");
    eSource.add(eModel);
    e.add(eSource);

    e.addAttribute("name", p_sName);
    n.add(e);

}