List of usage examples for org.w3c.dom Node getLocalName
public String getLocalName();
From source file:eu.impact_project.wsclient.XmlServiceProvider.java
private Service createServiceObjectFor(Node service) { int id = Integer.valueOf(service.getAttributes().getNamedItem("id").getTextContent()); String urlString = ""; String title = ""; String description = ""; NodeList nodes = service.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.item(i); String nodeName = node.getLocalName(); if (nodeName != null && nodeName.equals("url")) urlString = node.getTextContent(); else if (nodeName != null && nodeName.equals("title")) title = node.getTextContent(); else if (nodeName != null && nodeName.equals("description")) description = node.getTextContent().trim(); }/*w w w .j a va 2s.c o m*/ URL wsdlUrl = null; try { wsdlUrl = new URL(urlString); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (DOMException e) { // TODO Auto-generated catch block e.printStackTrace(); } Service result = new XmlService(id, title, description, wsdlUrl); return result; }
From source file:org.xmatthew.spy2servers.component.web.config.ServerPaser.java
private Connector[] parseConnector(Element element) { List<Connector> connectorList = new ArrayList<Connector>(); NodeList childNodes = element.getChildNodes(); Connector connector;//from w w w.ja va 2 s . co m for (int i = 0; i < childNodes.getLength(); i++) { Node child = childNodes.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { String localName = child.getLocalName(); if (NIO_CONNECTOR_ELEMENT.equals(localName)) { connector = parseNioConnector((Element) child); if (connector != null) connectorList.add(connector); } } } if (!connectorList.isEmpty()) { return connectorList.toArray(new Connector[connectorList.size()]); } return null; }
From source file:org.xmatthew.spy2servers.component.web.config.ServerPaser.java
private Handler[] parseHandlers(Element element) { List<Handler> handlerList = new ArrayList<Handler>(); NodeList childNodes = element.getChildNodes(); Handler handler;//w ww. j av a 2 s.c om for (int i = 0; i < childNodes.getLength(); i++) { Node child = childNodes.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { String localName = child.getLocalName(); if (HANDLER_ELEMENT.equals(localName)) { handler = parseHandler((Element) child); if (handler != null) handlerList.add(handler); } else if (SERVLET_ELEMENT.equals(localName)) { handlerList.add(paserWebViewServlet((Element) child)); } } } if (!handlerList.isEmpty()) { return handlerList.toArray(new Handler[handlerList.size()]); } return null; }
From source file:org.xmatthew.spy2servers.component.web.config.ServerPaser.java
protected void doParse(Element element, BeanDefinitionBuilder builder) { Connector[] connectors = null;/* w w w.ja va2s.co m*/ Handler[] handlers = null; NodeList childNodes = element.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node child = childNodes.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { String localName = child.getLocalName(); if (CONNECTORS_ELEMENT.equals(localName)) { connectors = parseConnector((Element) child); } else if (HANDLERS_ELEMENT.equals(localName)) { handlers = parseHandlers((Element) child); } } } if (connectors == null || connectors.length == 0) { throw new RuntimeException("sub element connectors must exsit and connector at least has one"); } builder.addPropertyValue(CONNECTORS_ELEMENT, connectors); if (handlers != null) { builder.addPropertyValue(HANDLERS_ELEMENT, handlers); } builder.setInitMethodName("run"); }
From source file:org.cleverbus.core.common.exception.AbstractSoapExceptionFilter.java
/** * Gets the exception name.//from w w w. java 2s. com * * @param detailNode the fault detail node * @return exception fully qualified name */ protected QName getExceptionName(Node detailNode) { Node exNode = getFirstElm(detailNode); return new QName(exNode.getNamespaceURI(), exNode.getLocalName()); }
From source file:org.opencredo.esper.config.xml.EsperStatementParser.java
/** * Parses out the individual statement elements for further processing. * //from ww w . j a v a 2 s . c o m * @param element * the esper-template context * @param parserContext * the parser's context * @return a set of initialized esper statements */ @SuppressWarnings("unchecked") public ManagedSet parseStatements(Element element, ParserContext parserContext) { ManagedSet statements = new ManagedSet(); NodeList childNodes = element.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node child = childNodes.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { Element childElement = (Element) child; String localName = child.getLocalName(); if ("statement".equals(localName)) { BeanDefinition definition = parserContext.getDelegate().parseCustomElement(childElement); statements.add(definition); } else if ("ref".equals(localName)) { String ref = childElement.getAttribute("bean"); statements.add(new RuntimeBeanReference(ref)); } } } return statements; }
From source file:org.cleverbus.core.common.ws.HeaderAndPayloadValidatingInterceptor.java
/** * Checks if input request should be ignored from header checking. * * @param messageContext the msg context * @return {@code true} when input request should be ignored, otherwise {@code false} */// w ww .j a va2 s . c om private boolean ignoreRequest(MessageContext messageContext) { Node reqNode = ((DOMSource) messageContext.getRequest().getPayloadSource()).getNode(); QName reqName = new QName(reqNode.getNamespaceURI(), reqNode.getLocalName()); return ignoreRequests.contains(reqName); }
From source file:com.vmware.identity.wstrust.client.impl.AcquireTokenByGssResponseHandler.java
/** * Helper: Whether response contains an RSTRC * * @param node//ww w .java2s .c o m * the root of the DOM tree to search for TSTRC. * @return true if rstrc is founf false otherwise. */ private boolean hasRSTRC(Node node) throws ParserException { boolean found = false; if ((RSTRC_ELEMENT_NAME.equalsIgnoreCase(node.getLocalName())) && RSTRC_NAMESPACE.equalsIgnoreCase(node.getNamespaceURI())) { log.debug("Node is the RSTRC."); found = true; } else { NodeList rstrcNodes = ((Element) node).getElementsByTagNameNS(RSTRC_NAMESPACE, RSTRC_ELEMENT_NAME); log.debug( String.format("Found %d RSTRC elements.", ((rstrcNodes == null) ? 0 : rstrcNodes.getLength()))); found = (rstrcNodes.getLength() > 0); } return found; }
From source file:eu.scape_project.planning.evaluation.evaluators.XmlExtractor.java
public HashMap<String, String> extractValues(Document xml, String path) { try {//from w ww . ja va 2 s .com HashMap<String, String> resultMap = new HashMap<String, String>(); XPathFactory factory = XPathFactory.newInstance(); XPath xpath = factory.newXPath(); xpath.setNamespaceContext(namespaceContext); XPathExpression expr = xpath.compile(path); NodeList list = (NodeList) expr.evaluate(xml, XPathConstants.NODESET); if (list != null) { for (int i = 0; i < list.getLength(); i++) { Node n = list.item(i); String content = n.getTextContent(); if (content != null) { resultMap.put(n.getLocalName(), content); } } } return resultMap; } catch (Exception e) { log.error("Could not parse XML " + " searching for path " + path + ": " + e.getMessage(), e); return null; } }