Example usage for org.dom4j DocumentHelper createElement

List of usage examples for org.dom4j DocumentHelper createElement

Introduction

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

Prototype

public static Element createElement(String name) 

Source Link

Usage

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

License:Open Source License

public void addPageBodyContents() {
    Element n = (Element) oDocument.selectSingleNode("/report/layouts/layout/reportPages/page/pageBody");
    if (n == null) {
        addPageBody();//from   ww w.  ja v  a2s.c o  m
        n = (Element) oDocument.selectSingleNode("/report/layouts/layout/reportPages/page/pageBody");
    }

    Element e = DocumentHelper.createElement("contents");
    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();/*w w  w  . j  av  a 2  s  .c  o  m*/
        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 addStyle(String p_sName) {
    String sName = p_sName;/*from   w w  w.  j  a v  a 2s .  co m*/
    String quotChar = "\'";
    if (sName.indexOf(quotChar) >= 0) {
        quotChar = "\"";
    }
    String elementString = "/report/layouts/layout/reportPages/page/pageBody/contents/list[@refQuery="
            + quotChar + sName + quotChar + "]";
    Element n = (Element) oDocument.selectSingleNode(elementString);
    if (n == null) {
        addList(p_sName);
        n = (Element) oDocument.selectSingleNode(elementString);
    }
    Element e = DocumentHelper.createElement("style");
    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   w w w. j a va 2s  .  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 void addQueries() {
    Element e = DocumentHelper.createElement("queries");
    oDocument.getRootElement().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);// w  w w  .  jav a  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 2  s .co  m
        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);

}

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

License:Open Source License

public void addSelection() {
    Element n = (Element) oDocument.selectSingleNode("/report/queries/query");
    if (n == null) {
        addQuery();//from  w  ww.  j ava2 s  .c  om
        n = (Element) oDocument.selectSingleNode("/report/queries/query");
    }

    Element eSelection = DocumentHelper.createElement("selection");
    n.add(eSelection);
}

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

License:Open Source License

public void addDataItem(String p_sName, String p_sExpression, boolean p_bAggregate, String p_sSort) {
    Element nSelection = (Element) oDocument.selectSingleNode("/report/queries/query/selection");
    if (nSelection == null) {
        addSelection();//from   w  w w . j  av a  2s  .com
        nSelection = (Element) oDocument.selectSingleNode("/report/queries/query/selection");
    }

    // Create the dataItem element
    Element eDataItem = DocumentHelper.createElement("dataItem");
    eDataItem.addAttribute("name", p_sName);

    // Add an aggregation element, if necessary
    if (p_bAggregate) {
        eDataItem.addAttribute("aggregate", "true");
    }

    // Add the expression for the dataItem
    Element eExpression = DocumentHelper.createElement("expression");
    eExpression.setText(p_sExpression);
    eDataItem.add(eExpression);

    // Add the dataItem to the selection element
    nSelection.add(eDataItem);

    // add the sort item to the report, if necessary
    if (p_sSort != null && !p_sSort.equals("")) {
        addDataItemSort(p_sName, p_sSort);
    }
}

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

License:Open Source License

public void addModelPath(String p_sName) {
    Element n = (Element) oDocument.getRootElement();

    Element eModelPath = DocumentHelper.createElement("modelPath");
    eModelPath.setText(p_sName + "/model[@name='model']");

    n.add(eModelPath);/*from ww w.j a v a  2 s .  com*/
}