Example usage for org.dom4j Namespace XML_NAMESPACE

List of usage examples for org.dom4j Namespace XML_NAMESPACE

Introduction

In this page you can find the example usage for org.dom4j Namespace XML_NAMESPACE.

Prototype

Namespace XML_NAMESPACE

To view the source code for org.dom4j Namespace XML_NAMESPACE.

Click Source Link

Document

XML Namespace

Usage

From source file:org.orbeon.oxf.processor.tamino.dom4j.TDOM4JXMLOutputter.java

License:Open Source License

/**
 ** Gets all the declared namespaces starting at the given element and accumulates the detected namespaces
 ** within the given namespace stack. The given namespace stack is also returned as the result.
 ** Please note, that this method has been added for the purpose that not always all given namespaces
 ** are serialized if they are already given for an ancestor.
 **//* w  w w . j  av  a2  s .c o m*/
private TDOM4JNamespaceStack getParentNamespaces(Element element, TDOM4JNamespaceStack namespaces) {

    if (element == null)
        return namespaces;

    if (element.getParent() != null)
        namespaces = getParentNamespaces(element.getParent(), namespaces);

    Namespace ns = element.getNamespace();

    // Add namespace decl only if it's not the XML namespace and it's
    // not the NO_NAMESPACE with the prefix "" not yet mapped
    // (we do output xmlns="" if the "" prefix was already used and we
    // need to reclaim it for the NO_NAMESPACE)
    if (ns != Namespace.XML_NAMESPACE && !(ns == Namespace.NO_NAMESPACE && namespaces.getURI("") == null)) {
        String prefix = ns.getPrefix();
        String uri = namespaces.getURI(prefix);
        // Put a new namespace declaratation into the namespace stack
        if (!ns.getURI().equals(uri)) {
            namespaces.push(ns);
        }
    }

    // Add additional namespace declarations if not given yet
    List additionalNamespaces = element.additionalNamespaces();
    if (additionalNamespaces != null) {
        for (int i = 0; i < additionalNamespaces.size(); i++) {
            Namespace additional = (Namespace) additionalNamespaces.get(i);
            String prefix = additional.getPrefix();
            String uri = namespaces.getURI(prefix);
            if (!additional.getURI().equals(uri))
                namespaces.push(additional);
        }
    }

    return namespaces;

}

From source file:org.talend.camel.designer.CamelDesignerCoreService.java

License:Open Source License

private void addManifestContent(Item item, Element jobElement) {
    Element manifestElement = jobElement.addElement("RouteManifest");
    manifestElement.addAttribute(QName.get("space", Namespace.XML_NAMESPACE), "preserve");

    final DependenciesResolver resolver = new DependenciesResolver((ProcessItem) item);
    manifestElement.addElement(ManifestItem.IMPORT_PACKAGE).addText(resolver.getManifestImportPackage('\n'));
    manifestElement.addElement(ManifestItem.EXPORT_PACKAGE).addText(resolver.getManifestExportPackage('\n'));
    manifestElement.addElement(ManifestItem.REQUIRE_BUNDLE).addText(resolver.getManifestRequireBundle('\n'));
    manifestElement.addElement(ManifestItem.BUNDLE_CLASSPATH)
            .addText(resolver.getManifestBundleClasspath('\n'));
}

From source file:org.talend.camel.designer.CamelDesignerCoreService.java

License:Open Source License

private void addSpringContent(Item item, Element jobElement) {
    Element routeSpringElement = jobElement.addElement("RouteSpring");
    routeSpringElement.addAttribute(QName.get("space", Namespace.XML_NAMESPACE), "preserve");
    String springContent = ((CamelProcessItem) item).getSpringContent();
    routeSpringElement.addText(springContent);
}