Example usage for org.dom4j.dom DOMElement addNamespace

List of usage examples for org.dom4j.dom DOMElement addNamespace

Introduction

In this page you can find the example usage for org.dom4j.dom DOMElement addNamespace.

Prototype

public Element addNamespace(String prefix, String uri) 

Source Link

Usage

From source file:GnuCash.GnuCashDocument.java

License:Open Source License

public void addCommodity(String isin, String symbol, String name, String space) {
    setBook();// w  w w . j ava 2  s  . co m

    //Element e=book.addElement("gnc:commodity");
    DOMElement e = new DOMElement("gnc:commodity");
    e.addAttribute("version", CMDTY_VERSION);
    e.addNamespace("cmdty", "http://www.gnucash.org/XML/cmdty");
    e.addElement("cmdty:space").setText(space);
    e.addElement("cmdty:id").setText(symbol);
    e.addElement("cmdty:xcode").setText(isin);
    e.addElement("cmdty:name").setText(name);
    e.addElement("cmdty:fraction").setText(CMDTY_FRACTION);
    e.addElement("cmdty:get_quotes");
    e.addElement("cmdty:quote_source").setText(CMDTY_QUOTE_SOURCE);
    e.addElement("cmdty:quote_tz");

    book.elements("commodity").add(1, e);

    modified = true;
    /*
     *  <gnc:commodity version="2.0.0">
    <cmdty:space>XETRA</cmdty:space>
    <cmdty:id>586590</cmdty:id>
    <cmdty:name>Grenkeleasing AG</cmdty:name>
    <cmdty:fraction>10000</cmdty:fraction>
    <cmdty:get_quotes/>
    <cmdty:quote_source>vwd</cmdty:quote_source>
    <cmdty:quote_tz/>
    </gnc:commodity>
     */
}