Example usage for org.dom4j QName get

List of usage examples for org.dom4j QName get

Introduction

In this page you can find the example usage for org.dom4j QName get.

Prototype

public static QName get(String qualifiedName, String uri) 

Source Link

Usage

From source file:org.orbeon.oxf.xforms.RuntimeBind.java

License:Open Source License

public QName evaluateTypeQName(Map<String, String> namespaceMap) {
    final String typeQNameString = staticBind.dataTypeOrNull();
    if (typeQNameString != null) {
        final String typeNamespacePrefix;
        final String typeNamespaceURI;
        final String typeLocalname;

        final int prefixPosition = typeQNameString.indexOf(':');
        if (prefixPosition > 0) {
            typeNamespacePrefix = typeQNameString.substring(0, prefixPosition);
            typeNamespaceURI = namespaceMap.get(typeNamespacePrefix);
            if (typeNamespaceURI == null)
                throw new ValidationException("Namespace not declared for prefix '" + typeNamespacePrefix + "'",
                        staticBind.locationData());

            // TODO: xxx check what XForms event must be dispatched

            typeLocalname = typeQNameString.substring(prefixPosition + 1);
        } else {//from w ww.  j  a v a2 s.c  o m
            typeNamespacePrefix = "";
            typeNamespaceURI = "";
            typeLocalname = typeQNameString;
        }

        return QName.get(typeLocalname, new Namespace(typeNamespacePrefix, typeNamespaceURI));
    } else {
        return null;
    }
}

From source file:org.soxmpp.server.xmpp.handler.IQAuthHandler.java

License:Open Source License

/**
 * Constructor./*w  ww  . jav a  2  s . c om*/
 */
public IQAuthHandler() {

    probeResponse = DocumentHelper.createElement(QName.get("query", NAMESPACE));
    probeResponse.addElement("username");
    if (AuthManager.isPlainSupported()) {
        probeResponse.addElement("password");
    }
    if (AuthManager.isDigestSupported()) {
        probeResponse.addElement("digest");
    }
    probeResponse.addElement("resource");
}

From source file:org.soxmpp.server.xmpp.handler.IQRegisterHandler.java

License:Open Source License

/**
 * Constructor.//ww  w.j a va 2  s  .  c  om
 */
public IQRegisterHandler() {
    probeResponse = DocumentHelper.createElement(QName.get("query", NAMESPACE));
    probeResponse.addElement("username");
    probeResponse.addElement("password");
    probeResponse.addElement("email");
    probeResponse.addElement("name");
}

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);
}

From source file:org.talend.camel.designer.ui.wizards.export.RouteJavaScriptOSGIForESBManager.java

License:Open Source License

private static void moveNamespace(Element treeRoot, Namespace oldNsp, Namespace newNsp) {
    if (treeRoot.getNamespace().equals(oldNsp)) {
        treeRoot.setQName(QName.get(treeRoot.getName(), newNsp));
        treeRoot.remove(oldNsp);//from   ww w.j a v a2s  .  co  m
    }
    moveNamespaceInChildren(treeRoot, oldNsp, newNsp);
}

From source file:org.talend.camel.designer.ui.wizards.export.RouteJavaScriptOSGIForESBManager.java

License:Open Source License

private static void moveNamespaceInChildren(Element treeRoot, Namespace oldNsp, Namespace newNsp) {
    for (Iterator<?> i = treeRoot.elementIterator(); i.hasNext();) {
        Element e = (Element) i.next();
        if (e.getNamespace().equals(oldNsp)) {
            e.setQName(QName.get(e.getName(), newNsp));
            e.remove(oldNsp);//from  w w w. jav a  2  s . c om
        }
        moveNamespaceInChildren(e, oldNsp, newNsp);
    }
}

From source file:org.talend.camel.designer.ui.wizards.export.RouteJavaScriptOSGIForESBManager.java

License:Open Source License

private static void moveNamespace(Element treeRoot, String oldNspURI, String newNspURI) {
    Namespace oldNsp = treeRoot.getNamespace();
    if (oldNspURI.equals(oldNsp.getURI())) {
        Namespace newNsp = Namespace.get(oldNsp.getPrefix(), newNspURI);
        treeRoot.setQName(QName.get(treeRoot.getName(), newNsp));
        treeRoot.remove(oldNsp);/*from  www  . j  a  v  a 2 s  .co m*/
    }
    moveNamespaceInChildren(treeRoot, oldNspURI, newNspURI);
}

From source file:org.talend.camel.designer.ui.wizards.export.RouteJavaScriptOSGIForESBManager.java

License:Open Source License

private static void moveNamespaceInChildren(Element treeRoot, String oldNspURI, String newNspURI) {
    for (Iterator<?> i = treeRoot.elementIterator(); i.hasNext();) {
        Element e = (Element) i.next();
        Namespace oldNsp = e.getNamespace();
        if (oldNspURI.equals(oldNsp.getURI())) {
            Namespace newNsp = Namespace.get(oldNsp.getPrefix(), newNspURI);
            e.setQName(QName.get(e.getName(), newNsp));
            e.remove(oldNsp);//  w  w  w  .  j  a  v  a  2  s.c om
        }
        moveNamespaceInChildren(e, oldNspURI, newNspURI);
    }
}

From source file:org.xmpp.packet.Packet.java

License:Open Source License

/**
 * Returns a {@link PacketExtension} on the first element found in this packet
 * for the specified <tt>name</tt> and <tt>namespace</tt> or <tt>null</tt> if
 * none was found./*  w w w  . java2s  .  c om*/
 *
 * @param name the child element name.
 * @param namespace the child element namespace.
 * @return a PacketExtension on the first element found in this packet for the specified
 *         name and namespace or null if none was found.
 */
public PacketExtension getExtension(String name, String namespace) {
    List extensions = element.elements(QName.get(name, namespace));
    if (!extensions.isEmpty()) {
        Class extensionClass = PacketExtension.getExtensionClass(name, namespace);
        // If a specific PacketExtension implementation has been registered, use that.
        if (extensionClass != null) {
            try {
                Constructor constructor = extensionClass.getDeclaredConstructor(Element.class);
                return (PacketExtension) constructor.newInstance(extensions.get(0));
            } catch (Exception e) {
                // Ignore.
            }
        }
        // Otherwise, use a normal PacketExtension.
        else {
            return new PacketExtension((Element) extensions.get(0));
        }
    }
    return null;
}