Example usage for org.w3c.dom Node getNamespaceURI

List of usage examples for org.w3c.dom Node getNamespaceURI

Introduction

In this page you can find the example usage for org.w3c.dom Node getNamespaceURI.

Prototype

public String getNamespaceURI();

Source Link

Document

The namespace URI of this node, or null if it is unspecified (see ).

Usage

From source file:org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBindingParser.java

private boolean isJAXWSMethodElement(Node node) {
    return ToolConstants.NS_JAXWS_BINDINGS.equals(node.getNamespaceURI())
            && "method".equals(node.getLocalName());
}

From source file:org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBindingParser.java

private boolean isPackageElement(Node node) {
    return ToolConstants.NS_JAXWS_BINDINGS.equals(node.getNamespaceURI())
            && "package".equals(node.getLocalName());
}

From source file:org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBindingParser.java

private boolean isJAXWSParameterElement(Node node) {
    return (ToolConstants.NS_JAXWS_BINDINGS.equals(node.getNamespaceURI()))
            && "parameter".equals(node.getLocalName());

}

From source file:org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBindingParser.java

private boolean isJAXWSClass(Node node) {
    return (ToolConstants.NS_JAXWS_BINDINGS.equals(node.getNamespaceURI()))
            && "class".equals(node.getLocalName());
}

From source file:org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBindingParser.java

private boolean isJAXWSClassDoc(Node node) {
    return (ToolConstants.NS_JAXWS_BINDINGS.equals(node.getNamespaceURI()))
            && "javadoc".equals(node.getLocalName());
}

From source file:org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBindingParser.java

private Boolean isAsyncElement(Node node) {
    return "enableAsyncMapping".equals(node.getLocalName())
            && ToolConstants.NS_JAXWS_BINDINGS.equals(node.getNamespaceURI());
}

From source file:org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBindingParser.java

private Boolean isWrapperStyle(Node node) {
    return "enableWrapperStyle".equals(node.getLocalName())
            && ToolConstants.NS_JAXWS_BINDINGS.equals(node.getNamespaceURI());
}

From source file:org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBindingParser.java

private Boolean isMIMEElement(Node node) {
    return "enableMIMEContent".equals(node.getLocalName())
            && ToolConstants.NS_JAXWS_BINDINGS.equals(node.getNamespaceURI());
}

From source file:org.apache.geode.management.internal.configuration.utils.XmlUtils.java

/**
 * Upgrade the schema of a given Config XMl <code>document</code> to the given
 * <code>namespace</code>, <code>schemaLocation</code> and <code>version</code>.
 * //www .  java  2  s  . c  om
 * @param document Config XML {@link Document} to upgrade.
 * @param namespaceUri Namespace URI to upgrade to.
 * @param schemaLocation Schema location to upgrade to.
 * @throws XPathExpressionException
 * @throws ParserConfigurationException
 * @since GemFire 8.1
 */
public static Document upgradeSchema(Document document, final String namespaceUri, final String schemaLocation,
        String schemaVersion) throws XPathExpressionException, ParserConfigurationException {
    if (StringUtils.isBlank(namespaceUri)) {
        throw new IllegalArgumentException("namespaceUri");
    }
    if (StringUtils.isBlank(schemaLocation)) {
        throw new IllegalArgumentException("schemaLocation");
    }
    if (StringUtils.isBlank(schemaVersion)) {
        throw new IllegalArgumentException("schemaVersion");
    }

    if (null != document.getDoctype()) {
        Node root = document.getDocumentElement();
        Document copiedDocument = getDocumentBuilder().newDocument();
        Node copiedRoot = copiedDocument.importNode(root, true);
        copiedDocument.appendChild(copiedRoot);
        document = copiedDocument;
    }

    final Element root = document.getDocumentElement();
    // since root is the cache element, then this oldNamespace will be the cache's namespaceURI
    String oldNamespaceUri = root.getNamespaceURI();

    // update the namespace
    if (!namespaceUri.equals(oldNamespaceUri)) {
        changeNamespace(root, oldNamespaceUri, namespaceUri);
    }

    // update the version
    root.setAttribute("version", schemaVersion);

    // update the schemaLocation attribute
    Node schemaLocationAttr = root.getAttributeNodeNS(W3C_XML_SCHEMA_INSTANCE_NS_URI,
            W3C_XML_SCHEMA_INSTANCE_ATTRIBUTE_SCHEMA_LOCATION);
    String xsiPrefix = findPrefix(root, W3C_XML_SCHEMA_INSTANCE_NS_URI);
    ;
    Map<String, String> uriToLocation = new HashMap<>();
    if (schemaLocationAttr != null) {
        uriToLocation = buildSchemaLocationMap(schemaLocationAttr.getNodeValue());
    } else if (xsiPrefix == null) {
        // this namespace is not defined yet, define it
        xsiPrefix = W3C_XML_SCHEMA_INSTANCE_PREFIX;
        root.setAttribute("xmlns:" + xsiPrefix, W3C_XML_SCHEMA_INSTANCE_NS_URI);
    }

    uriToLocation.remove(oldNamespaceUri);
    uriToLocation.put(namespaceUri, schemaLocation);

    root.setAttributeNS(W3C_XML_SCHEMA_INSTANCE_NS_URI,
            xsiPrefix + ":" + W3C_XML_SCHEMA_INSTANCE_ATTRIBUTE_SCHEMA_LOCATION,
            getSchemaLocationValue(uriToLocation));

    return document;
}

From source file:org.apache.geode.management.internal.configuration.utils.XmlUtils.java

/**
 * Change the namespace URI of a <code>node</code> and its children to
 * <code>newNamespaceUri</code> if that node is in the given <code>oldNamespaceUri</code>
 * namespace URI.//  w  ww .j av a 2 s .  c  o  m
 * 
 * 
 * @param node {@link Node} to change namespace URI on.
 * @param oldNamespaceUri old namespace URI to change from.
 * @param newNamespaceUri new Namespace URI to change to.
 * @throws XPathExpressionException
 * @return the modified version of the passed in node.
 * @since GemFire 8.1
 */
static Node changeNamespace(final Node node, final String oldNamespaceUri, final String newNamespaceUri)
        throws XPathExpressionException {
    Node result = null;
    final NodeList nodes = query(node, "//*");
    for (int i = 0; i < nodes.getLength(); i++) {
        final Node element = nodes.item(i);
        if (element.getNamespaceURI() == null || element.getNamespaceURI().equals(oldNamespaceUri)) {
            Node renamed = node.getOwnerDocument().renameNode(element, newNamespaceUri, element.getNodeName());
            if (element == node) {
                result = renamed;
            }
        }
    }
    return result;
}