List of usage examples for org.w3c.dom Element getNamespaceURI
public String getNamespaceURI();
null
if it is unspecified (see ). From source file:dk.dbc.rawrepo.oai.OAIWorker.java
private void fixXmlNamespacePrefix(Element element, String metadataPrefix) throws DOMException { String namespaceURI = element.getNamespaceURI(); if (namespaceURI == null) { return;/*w ww . j a v a 2 s. c o m*/ } fixXmlNamespacePrefix(element, metadataPrefix, namespaceURI); }
From source file:com.rest4j.generator.Generator.java
private void cleanupBeforePostprocess(Element element) { if ("http://www.w3.org/1999/xhtml".equals(element.getNamespaceURI())) { element.getOwnerDocument().renameNode(element, null, element.getLocalName()); }//from w w w . j av a2s. c o m for (Node child : Util.it(element.getChildNodes())) { if (child instanceof Element) { cleanupBeforePostprocess((Element) child); } } }
From source file:com.rest4j.generator.Generator.java
private void cleanupFinal(Element element) { if ("http://www.w3.org/1999/xhtml".equals(element.getNamespaceURI())) { element.getOwnerDocument().renameNode(element, null, element.getLocalName()); }/*from w w w. java 2 s. c o m*/ NamedNodeMap attrs = element.getAttributes(); if (attrs.getNamedItem("xmlns") != null) { attrs.removeNamedItem("xmlns"); } if (attrs.getNamedItem("xmlns:html") != null) { attrs.removeNamedItem("xmlns:html"); } for (Node child : Util.it(element.getChildNodes())) { if (child instanceof Element) { cleanupFinal((Element) child); } } }
From source file:eu.europa.esig.dss.tsl.service.TSLParser.java
private void fillPointerTerritoryAndMimeType(OtherTSLPointerType otherTSLPointerType, TSLPointer pointer) { List<Serializable> textualInformationOrOtherInformation = otherTSLPointerType.getAdditionalInformation() .getTextualInformationOrOtherInformation(); if (CollectionUtils.isNotEmpty(textualInformationOrOtherInformation)) { Map<String, String> properties = new HashMap<String, String>(); for (Serializable serializable : textualInformationOrOtherInformation) { if (serializable instanceof AnyType) { AnyType anyInfo = (AnyType) serializable; for (Object content : anyInfo.getContent()) { if (content instanceof JAXBElement) { @SuppressWarnings("rawtypes") JAXBElement jaxbElement = (JAXBElement) content; properties.put(jaxbElement.getName().toString(), jaxbElement.getValue().toString()); } else if (content instanceof Element) { Element element = (Element) content; properties.put("{" + element.getNamespaceURI() + "}" + element.getLocalName(), element.getTextContent()); }/*from w w w . j a va 2 s .c om*/ } } } pointer.setMimeType(properties.get("{http://uri.etsi.org/02231/v2/additionaltypes#}MimeType")); pointer.setTerritory(properties.get("{http://uri.etsi.org/02231/v2#}SchemeTerritory")); } }
From source file:dk.dbc.rawrepo.oai.OAIWorker.java
private void fixXmlNamespacePrefix(Element element, String metadataPrefix, String namespaceURI) throws DOMException { String prefix = null;/*from w w w . j a va2 s. co m*/ if (namespaceURI.equals(element.getNamespaceURI())) { prefix = element.getPrefix(); if (prefix == null) { prefix = ""; } element.setPrefix(metadataPrefix); } for (Node child = element.getFirstChild(); child != null; child = child.getNextSibling()) { if (child.getNodeType() == Node.ELEMENT_NODE) { fixXmlNamespacePrefix((Element) child, metadataPrefix, namespaceURI); } } if (prefix != null) { element.removeAttribute(prefix.isEmpty() ? "xmlns" : ("xmlns:" + prefix)); } }
From source file:cz.incad.kramerius.service.replication.ExternalReferencesFormat.java
private void changeDatastreamVersion(Document document, Element datastream, Element version, URL url) throws IOException { InputStream is = null;/*w w w .j av a 2s .c o m*/ try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); URLConnection urlConnection = url.openConnection(); is = urlConnection.getInputStream(); IOUtils.copyStreams(is, bos); version.setAttribute("SIZE", "" + bos.size()); version.removeChild(XMLUtils.findElement(version, "contentLocation", version.getNamespaceURI())); Element binaryContent = document.createElementNS(version.getNamespaceURI(), "binaryContent"); document.adoptNode(binaryContent); binaryContent.setTextContent(new String(Base64.encodeBase64(bos.toByteArray()))); version.appendChild(binaryContent); datastream.setAttribute("CONTROL_GROUP", "M"); } finally { IOUtils.tryClose(is); } }
From source file:com.castlemock.web.mock.soap.model.project.service.CreateSoapPortsService.java
/** * The method provides the functionality to extract SOAP operation from a document * @param document The document which will be parsed * @param soapPortBinding The SOAP port binding which the operations belongs to * @param soapOperationAddress The address that will be assigned as the default address to the operations * @param soapVersion The SOAP operation version (SOAP 11 or SOAP 12) * @param generateResponse Boolean value determining if a response should be generated for each extracted * operation./*from w ww. j a va 2 s . c o m*/ * @return A list of extracted SOAP operations */ private List<SoapOperationDto> getSoapOperations(final Document document, final String soapPortBinding, final String soapOperationAddress, final SoapVersion soapVersion, final boolean generateResponse) { final List<SoapOperationDto> soapOperations = new LinkedList<SoapOperationDto>(); final Element bindingElement = findElement(document, WSDL_NAMESPACE, "binding", soapPortBinding); if (bindingElement == null) { return soapOperations; } final String bindingType = getAttribute(bindingElement, "type"); if (bindingType == null) { return soapOperations; } final Element portTypeElement = findElement(document, WSDL_NAMESPACE, "portType", bindingType); if (portTypeElement == null) { return soapOperations; } final NodeList operationNodeList = portTypeElement.getElementsByTagNameNS(WSDL_NAMESPACE, "operation"); for (int operationIndex = 0; operationIndex < operationNodeList.getLength(); operationIndex++) { final Node operationNode = operationNodeList.item(operationIndex); if (operationNode.getNodeType() == Node.ELEMENT_NODE) { final Element operationElement = (Element) operationNode; final String operationName = getAttribute(operationElement, "name"); final SoapOperationDto soapOperation = new SoapOperationDto(); final String defaultBody = generateDefaultBody(operationName, operationElement.getNamespaceURI()); final String inputMessageName = getInputMessageName(operationElement); final String identifier = inputMessageName != null && !inputMessageName.isEmpty() ? inputMessageName : operationName; soapOperation.setName(operationName); soapOperation.setIdentifier(identifier); soapOperation.setHttpMethod(HttpMethod.POST); soapOperation.setStatus(SoapOperationStatus.MOCKED); soapOperation.setResponseStrategy(SoapResponseStrategy.RANDOM); soapOperation.setForwardedEndpoint(soapOperationAddress); soapOperation.setOriginalEndpoint(soapOperationAddress); soapOperation.setSoapVersion(soapVersion); soapOperation.setMockResponses(new ArrayList<SoapMockResponseDto>()); soapOperation.setDefaultBody(defaultBody); soapOperation.setCurrentResponseSequenceIndex(DEFAULT_RESPONSE_SEQUENCE_INDEX); if (generateResponse) { final SoapMockResponseDto mockResponse = new SoapMockResponseDto(); mockResponse.setBody(soapOperation.getDefaultBody()); mockResponse.setStatus(SoapMockResponseStatus.ENABLED); mockResponse.setName(AUTO_GENERATED_MOCK_RESPONSE_DEFAULT_NAME); mockResponse.setHttpStatusCode(DEFAULT_HTTP_STATUS_CODE); soapOperation.getMockResponses().add(mockResponse); } soapOperations.add(soapOperation); } } return soapOperations; }
From source file:de.betterform.xml.xforms.action.LoadAction.java
private void destroyembeddedModels(Element targetElem) throws XFormsException { NodeList childNodes = targetElem.getChildNodes(); for (int index = 0; index < childNodes.getLength(); index++) { Node node = childNodes.item(index); if (node.getNodeType() == Node.ELEMENT_NODE) { Element elementImpl = (Element) node; String name = elementImpl.getLocalName(); String uri = elementImpl.getNamespaceURI(); if (NamespaceConstants.XFORMS_NS.equals(uri) && name.equals(XFormsConstants.MODEL)) { Model model = (Model) elementImpl.getUserData(""); if (LOGGER.isDebugEnabled()) { LOGGER.debug("dispatch 'model-destruct' event to embedded model: " + model.getId()); ;/*from w w w .j av a 2 s. c o m*/ } String modelId = model.getId(); // do not dispatch model-destruct to avoid problems in lifecycle // TODO: review: this.container.dispatch(model.getTarget(), XFormsEventNames.MODEL_DESTRUCT, null); model.dispose(); this.container.removeModel(model); model = null; if (Config.getInstance().getProperty("betterform.debug-allowed").equals("true")) { Map contextInfo = new HashMap(1); contextInfo.put("modelId", modelId); this.container.dispatch(this.target, BetterFormEventNames.MODEL_REMOVED, contextInfo); } } else { destroyembeddedModels(elementImpl); } } } }
From source file:com.verisign.epp.codec.gen.EPPUtil.java
/** * Gets all of the direct child element with a given tag name and XML * namespace.//from w w w . j a v a 2s .co m * * @param aNS * XML namespace of the elements. For example, for domain element * this is "urn:iana:xmlns:domain". * @param aTagName * Tag name to scan for. * @return <code>Vector</code> of <code>Node</code> instances that are * elements and have the specified tag name and XML namespace. */ public static Vector getElementsByTagNameNS(Element aElement, String aNS, String aTagName) { Vector retVal = new Vector(); aTagName = EPPUtil.getLocalName(aTagName); NodeList theNodes = aElement.getChildNodes(); if (theNodes != null) { for (int i = 0; i < theNodes.getLength(); i++) { if (theNodes.item(i).getNodeType() == Node.ELEMENT_NODE) { Element currElm = (Element) theNodes.item(i); if (currElm.getNamespaceURI().equals(aNS) && currElm.getLocalName().equals(aTagName)) { retVal.add(theNodes.item(i)); } } } } return retVal; }