Example usage for org.jdom2 Element getNamespace

List of usage examples for org.jdom2 Element getNamespace

Introduction

In this page you can find the example usage for org.jdom2 Element getNamespace.

Prototype

public Namespace getNamespace() 

Source Link

Document

Returns the element's Namespace .

Usage

From source file:se.miun.itm.input.model.param.Param.java

License:Open Source License

private void initFromOriginal(Element original) {
    // init attributes
    setNamespace(original.getNamespace());
    setName(original.getName());/*from ww w . ja  v a 2  s  .  c  om*/
    Attribute attr;
    for (Object content : original.getAttributes()) {
        attr = (Attribute) content;
        setAttribute(attr.getName(), attr.getValue());
    }

    // move children
    Element childE;
    Object[] children = original.getChildren().toArray();
    for (Object child : children) {
        childE = (Element) child;
        original.removeContent(childE);
        addContent(childE);
    }

    // attach to parent
    Element parent = original.getParentElement();
    parent.removeContent(original);
    parent.addContent(this);
}

From source file:ucar.unidata.idv.chooser.IdvRadarDatasetCollection.java

License:Open Source License

/**
 *  tds radar dataset collection  factory.
 *
 * @param desc the desc/*from  ww w.j a v a  2  s  . co  m*/
 * @param dsc_location the dsc_location
 * @param errlog the errlog
 * @return dataset collection
 * @throws IOException Signals that an I/O exception has occurred.
 */
static public IdvRadarDatasetCollection factory(String desc, String dsc_location, StringBuffer errlog)
        throws IOException {
    // super();
    SAXBuilder builder;
    Document doc = null;
    XMLEntityResolver jaxp = new XMLEntityResolver(true);
    builder = jaxp.getSAXBuilder();

    try {
        doc = builder.build(dsc_location);
    } catch (JDOMException e) {
        errlog.append(e.toString());
    }

    Element qcElem = doc.getRootElement();
    Namespace ns = qcElem.getNamespace();

    return new IdvRadarDatasetCollection(desc, dsc_location, qcElem, ns, errlog);
}

From source file:uk.co.platosys.boox.core.Boox.java

License:Open Source License

/**
 * This takes an org.jdom.Document argument instead of a java.io.File, but
 * does the same thing./*from w  w  w.  j  a v  a  2s .c o m*/
 *
 * @param clerk
 * @param document
 * @throws BooxException
 * @throws PermissionsException
* @throws BooxXMLException 
 */
public static void createLedgersAndAccounts(Enterprise enterprise, Clerk clerk, Document document)
        throws BooxException, PermissionsException, BooxXMLException {
    Element rootElement = document.getRootElement();
    Element ledgersElement = rootElement.getChild(LEDGERS_ELEMENT_NAME, ns);
    if (ledgersElement == null) {
        throw new BooxXMLException("ledgers schema docs faulty, no ledgers element");
    }
    if (ledgersElement.getNamespace() != ns) {
        throw new BooxXMLException("wrong namespace in schema documents");
    }

    logger.log("creating ledgers and accounts for " + enterprise.getName() + " from template document "
            + document.toString());
    createLedgersAndAccounts(enterprise, clerk, ledgersElement,
            openLedger(enterprise, Ledger.ROOT_LEDGER_NAME, clerk));

    Element tasksElement = rootElement.getChild(TASKS_ELEMENT_NAME, ns);
    if (tasksElement != null) {
        createTasks(enterprise, clerk, tasksElement);
    } //no requirement for a tasks element.
}