Java Code Examples for org.w3c.dom.Node#lookupNamespaceURI()
The following examples show how to use
org.w3c.dom.Node#lookupNamespaceURI() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DocumentModelAccess.java From netbeans with Apache License 2.0 | 6 votes |
public String lookupNamespaceURI(Node node, List<? extends Node> pathToRoot) { String prefix = node.getPrefix(); if (prefix == null) prefix = ""; //NOI18N String namespace = node.lookupNamespaceURI(prefix); if (namespace == null) { boolean skipDeeperNodes = true; for (Node n : pathToRoot) { if (skipDeeperNodes) { // The target node has to be inside of pathToRoot. // But it can be not a top element of the list. // It's necessary to skip items until the target node // isn't found in the list. if (areSameNodes(n, node)) { skipDeeperNodes = false; } } else { namespace = n.lookupNamespaceURI(prefix); if (namespace != null) { break; } } } } return namespace; }
Example 2
Source File: DOMUtils.java From cxf with Apache License 2.0 | 6 votes |
/** * Creates a QName object based on the qualified name * and using the Node as a base to lookup the namespace * for the prefix * @param qualifiedName * @param node */ public static QName createQName(String qualifiedName, Node node) { if (qualifiedName == null) { return null; } int index = qualifiedName.indexOf(':'); if (index == -1) { return new QName(qualifiedName); } String prefix = qualifiedName.substring(0, index); String localName = qualifiedName.substring(index + 1); String ns = node.lookupNamespaceURI(prefix); if (ns == null) { throw new RuntimeException("Invalid QName in mapping: " + qualifiedName); } return new QName(ns, localName, prefix); }
Example 3
Source File: IgnoreTagsDifferenceEvaluator.java From AuTe-Framework with Apache License 2.0 | 5 votes |
private String getNameSpaceFromPrefix(Node node) { final int beginIndex = node.getNodeValue().indexOf(':'); if (beginIndex == -1) { return ""; } return node.lookupNamespaceURI(node.getNodeValue().substring(0, beginIndex)); }
Example 4
Source File: RegexDifferenceListener.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
private String getNameSpaceFromPrefix(Node node) { final int beginIndex = node.getNodeValue().indexOf(":"); if (beginIndex == -1) { return ""; } return node.lookupNamespaceURI(node.getNodeValue().substring(0, beginIndex)); }
Example 5
Source File: RegexDifferenceListener.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
private String getNameSpaceFromPrefix(Node node) { final int beginIndex = node.getNodeValue().indexOf(":"); if (beginIndex == -1) { return ""; } return node.lookupNamespaceURI(node.getNodeValue().substring(0, beginIndex)); }
Example 6
Source File: EndpointReferenceUtils.java From cxf with Apache License 2.0 | 5 votes |
private static String getNameSpaceUri(Node node, String content, String namespaceURI) { if (namespaceURI == null) { namespaceURI = node.lookupNamespaceURI(content.substring(0, content.indexOf(':'))); } return namespaceURI; }
Example 7
Source File: RegexDifferenceListener.java From freehealth-connector with GNU Affero General Public License v3.0 | 4 votes |
private String getNameSpaceFromPrefix(Node node) { int beginIndex = node.getNodeValue().indexOf(":"); return beginIndex == -1 ? "" : node.lookupNamespaceURI(node.getNodeValue().substring(0, beginIndex)); }
Example 8
Source File: WSDL11SOAPOperationExtractor.java From carbon-apimgt with Apache License 2.0 | 4 votes |
private void readExtensionModel(ModelImpl model, Node node) { Node baseNode = node.getAttributes().getNamedItem(BASE_ATTR); if (baseNode == null) { return; } String baseName = baseNode.getNodeValue(); String refName; String nsName = null; if (baseName.contains(":")) { refName = baseNode.getNodeValue().split(":")[1]; nsName = baseNode.getNodeValue().split(":")[0]; } else { refName = baseName; } model.addProperty(BASE_CONTENT_KEYWORD, new RefProperty(refName)); if (nsName == null) { return; } if (isElementExist(refName, node.getOwnerDocument())) { log.debug(refName + ": is already defined inline."); return; } String ns = node.lookupNamespaceURI(nsName); if (ns == null) { log.debug("Couldn't find namespace for the " + refName + ". Hence skipping generating model."); return; } Document nsDoc = getBasedXSDofWSDL(ns); if (nsDoc == null) { log.warn("Couldn't find xsd document for namespace " + ns); } Node refNode = findFirstElementByName(refName, nsDoc); if (refNode == null) { log.warn("Couldn't find element " + refName + "from namespace " + ns); } ModelImpl newModel = new ModelImpl(); //only the refNode is handled. If children needs to handle, it's this method should calls over the children addModelDefinition(refNode, newModel, SOAPToRESTConstants.EMPTY_STRING, false, null); parameterModelMap.put(newModel.getName(), newModel); }
Example 9
Source File: CustomizationParser.java From cxf with Apache License 2.0 | 4 votes |
private void copyBindingsToWsdl(Node node, Node bindings, MapNamespaceContext ctx) { if (bindings.getNamespaceURI().equals(ToolConstants.JAXWS_BINDINGS.getNamespaceURI())) { bindings.setPrefix("jaxws"); } for (Map.Entry<String, String> ent : ctx.getUsedNamespaces().entrySet()) { if (node.lookupNamespaceURI(ent.getKey()) == null) { node.getOwnerDocument().getDocumentElement().setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns:" + ent.getKey(), ent.getValue()); } } Element element = DOMUtils.getFirstElement(bindings); while (element != null) { if (element.getNamespaceURI().equals(ToolConstants.JAXWS_BINDINGS.getNamespaceURI())) { element.setPrefix("jaxws"); } element = DOMUtils.getNextElement(element); } Node cloneNode = ProcessorUtil.cloneNode(node.getOwnerDocument(), bindings, true); Node firstChild = DOMUtils.getChild(node, "jaxws:bindings"); if (firstChild == null && cloneNode.getNodeName().indexOf("bindings") == -1) { wsdlNode.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns:jaxws", ToolConstants.JAXWS_BINDINGS.getNamespaceURI()); Element jaxwsBindingElement = node.getOwnerDocument() .createElementNS(ToolConstants.JAXWS_BINDINGS.getNamespaceURI(), "jaxws:bindings"); node.appendChild(jaxwsBindingElement); firstChild = jaxwsBindingElement; } if (firstChild == null && cloneNode.getNodeName().indexOf("bindings") > -1) { firstChild = node; if (wsdlNode.getAttributeNodeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "jaxws") == null) { wsdlNode.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns:jaxws", ToolConstants.JAXWS_BINDINGS.getNamespaceURI()); } } Element cloneEle = (Element)cloneNode; cloneEle.removeAttribute("node"); Element elem = DOMUtils.getFirstElement(cloneNode); while (elem != null) { Node attrNode = elem.getAttributeNode("node"); if (attrNode != null) { cloneNode.removeChild(elem); } elem = DOMUtils.getNextElement(elem); } if (firstChild != null) { firstChild.appendChild(cloneNode); } }