Example usage for org.dom4j DocumentHelper createNamespace

List of usage examples for org.dom4j DocumentHelper createNamespace

Introduction

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

Prototype

public static Namespace createNamespace(String prefix, String uri) 

Source Link

Usage

From source file:org.neuclear.exchange.contracts.ExchangeAgentGlobals.java

License:Open Source License

private static Namespace createNameSpace() {
    return DocumentHelper.createNamespace(EXA_NSPREFIX, EXAGENT_URI);
}

From source file:org.neuclear.exchange.orders.ExchangeOrderGlobals.java

License:Open Source License

public static Namespace createNameSpace() {
    return DocumentHelper.createNamespace(EX_NSPREFIX, EX_NSURI);
}

From source file:org.neuclear.xml.AbstractElementProxy.java

License:LGPL

protected AbstractElementProxy(final String name, final String prefix, final String nsURI) {
    this(name, DocumentHelper.createNamespace(prefix, nsURI));
}

From source file:simpel.FileHelper.java

License:GNU General Public License

public static String buildDeployFileContents(Process proc, Map<String, ServiceDetails> plMap,
        Map<String, ImportDetails> nsMap) {
    if (proc.getImports().size() == 0)
        return null;
    Document doc = DocumentHelper.createDocument();
    Namespace ns = DocumentHelper.createNamespace("", "http://www.apache.org/ode/schemas/dd/2007/03");
    Element root = doc.addElement(new QName("deploy", ns)).addNamespace("pns", proc.getTargetNamespace());

    Element pelement = root.addElement(new QName("process", ns)).addAttribute("name", "pns:" + proc.getName());
    pelement.addElement(new QName("active", ns)).addText("true");

    LinkedList<Element> invokes = new LinkedList<Element>();

    for (ServiceDetails sd : plMap.values()) {
        String prefix = sd.porttype.getQName().getPrefix();
        String uri = sd.porttype.getQName().getNamespaceURI();

        Element elem;/*  ww w  .  j a  va 2s .c o m*/
        if (sd.partnerlink.getMyRole() != null)
            elem = pelement.addElement(new QName("provide", ns));
        else {
            elem = DocumentHelper.createElement(new QName("invoke", ns));
            invokes.add(elem);
        }

        elem.addAttribute("partnerLink", sd.partnerlink.getName()).addElement("service")
                .addNamespace(prefix, uri).addAttribute("name", sd.service).addAttribute("port", sd.port);
    }

    for (Element inv : invokes)
        pelement.add(inv);

    StringWriter out = new StringWriter();
    OutputFormat format = OutputFormat.createPrettyPrint();
    XMLWriter writer = new XMLWriter(out, format);

    try {
        writer.write(doc);
    } catch (IOException e) {
        e.printStackTrace();
    }

    return out.toString();
}