List of usage examples for org.w3c.dom Node getLocalName
public String getLocalName();
From source file:fr.acxio.tools.agia.alfresco.configuration.DocumentDefinitionParser.java
@Override protected void doParse(Element sElement, ParserContext sParserContext, BeanDefinitionBuilder sBuilder) { // sBuilder is a NodeDefinitionFactoryBean super.doParse(sElement, sParserContext, sBuilder); sBuilder.addPropertyValue("contentPath", sElement.getAttribute(PROPDEF_CONTENTPATH)); sBuilder.addPropertyValue("mimeType", sElement.getAttribute(PROPDEF_MIMETYPE)); sBuilder.addPropertyValue("encoding", sElement.getAttribute(PROPDEF_ENCODING)); NodeList children = sElement.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node node = children.item(i); if (node instanceof Element) { String nodeName = node.getLocalName(); Element child = (Element) node; if (nodeName.equals(NODEDEF_PROPERTIES)) { sBuilder.addPropertyValue("propertiesDefinitions", parseProperties(child, sParserContext)); } else if (nodeName.equals(NODEDEF_ASPECTS)) { sBuilder.addPropertyValue("aspectsDefinitions", parseAspects(child)); } else if (nodeName.equals(NODEDEF_ASSOCIATIONS)) { sBuilder.addPropertyValue("associationsDefinitions", parseAssociations(child)); }/*from w w w .j a v a 2 s . co m*/ } } }
From source file:com.wavemaker.tools.ws.WebServiceToolsManager.java
/** * Returns the XML qualified name of the root element type for the given XML. *//*from www .jav a 2s . c o m*/ public static String getXmlRootElementType(String xml) throws ParserConfigurationException, SAXException, IOException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); DocumentBuilder db = dbf.newDocumentBuilder(); Reader reader = new StringReader(xml); Document doc = db.parse(new InputSource(reader)); Node node = doc.getFirstChild(); if (node != null) { String namespaceURI = node.getNamespaceURI(); String localName = node.getLocalName(); if (localName != null) { return namespaceURI == null ? localName : namespaceURI + ":" + localName; } } return null; }
From source file:com.clican.pluto.dataprocess.spring.parser.ConditionProcessorParser.java
@SuppressWarnings("unchecked") public void customiseBeanDefinition(BeanDefinition beanDef, Element element, ParserContext parserContext) { NodeList nodeList = element.getChildNodes(); ManagedMap processorMap = new ManagedMap(); ManagedMap exceptionMap = new ManagedMap(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { String localName = node.getLocalName(); if ("cond".equals(localName)) { Element condElement = (Element) node; String expr = condElement.getAttribute("expr"); String nextDataProcessor = condElement.getAttribute("nextDataProcessor"); String exception = condElement.getAttribute("exception"); if (StringUtils.isNotEmpty(exception)) { exceptionMap.put(expr, exception); } else if (StringUtils.isNotEmpty(nextDataProcessor)) { processorMap.put(expr, new RuntimeBeanReference(nextDataProcessor)); } else { processorMap.put(expr, null); }//from w w w . java 2s . c o m } } } beanDef.getPropertyValues().addPropertyValue("exceptionMap", exceptionMap); beanDef.getPropertyValues().addPropertyValue("dataProcessorMap", processorMap); }
From source file:com.trifork.batchcopy.client.BatchCopyClient.java
private String extractLastToken(Node atomFeedNode) { // <atom:feed .. // <atom:id> .. // <atom:updated> .. // <atom:title> .. // <atom:author> .. // <atom:entry> .. // .../*ww w . j a va 2 s. co m*/ // <atom:entry> // <atom:id>tag:nsi.dk,2011:doseringsforslag/dosageunit/v1/13709460140000000001</atom:id> // |- Sidste del af ovenstende ID er det offset vi skal sende med i nste request // ... // </atom:entry> NodeList childNodes = atomFeedNode.getLastChild().getChildNodes(); for (int i = 0; i < childNodes.getLength(); ++i) { Node currentChild = childNodes.item(i); if (currentChild.getLocalName().equals("id")) { String completeId = currentChild.getTextContent(); return completeId.substring(completeId.lastIndexOf("/") + 1); } } return null; }
From source file:org.xmatthew.spy2servers.component.config.TomcatJmxSpyComponentParser.java
protected void doParse(Element element, BeanDefinitionBuilder builder) { super.doParse(element, builder); DataSourcesSpy dataSourcesSpy = null; WebModuleSpy webModuleSpy = null;//from w w w. j a v a 2 s. co m 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 (DATASOURCES_SPY_PROPERTY.equals(localName)) { dataSourcesSpy = IntegrationNamespaceUtils.parseDataSourcesSpy((Element) child); } else if (WEB_MODULES_PROPERTY.equals(localName)) { webModuleSpy = IntegrationNamespaceUtils.parseWebModuleSpy((Element) child); } } } if (dataSourcesSpy != null) { builder.addPropertyValue(DATASOURCES_SPY_PROPERTY, dataSourcesSpy); } if (webModuleSpy != null) { builder.addPropertyValue(WEB_MODULES_PROPERTY, webModuleSpy); } builder.setScope(BeanDefinition.SCOPE_SINGLETON); }
From source file:org.echocat.jemoni.carbon.spring.Jmx2CarbonBridgeDefinitionParser.java
@Override protected void doParse(@Nonnull Element element, @Nonnull BeanDefinitionBuilder bean) { final String jmxRegistryRef = element.getAttribute(JMX_REGISTRY_REF_ATTRIBUTE); final String mBeanServerRef = element.getAttribute(MBEAN_SERVER_REF_ATTRIBUTE); if (hasText(jmxRegistryRef)) { if (hasText(mBeanServerRef)) { throw new IllegalArgumentException("The " + JMX_REGISTRY_REF_ATTRIBUTE + " and " + MBEAN_SERVER_REF_ATTRIBUTE + " attributes could not be used at the same time."); }// ww w . j a v a 2s. c o m bean.addConstructorArgReference(jmxRegistryRef); } else if (hasText(mBeanServerRef)) { bean.addConstructorArgReference(mBeanServerRef); } bean.addConstructorArgReference(element.getAttribute(WRITER_REF_ATTRIBUTE)); final String classLoaderRef = element.getAttribute(CLASS_LOADER_REF_ATTRIBUTE); if (hasText(classLoaderRef)) { bean.addPropertyReference("classLoader", classLoaderRef); } final String pathPrefix = element.getAttribute(PATH_PREFIX_ATTRIBUTE); if (hasText(pathPrefix)) { bean.addPropertyValue("pathPrefix", pathPrefix); } Configuration configuration = null; final NodeList children = element.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { final Node child = children.item(i); if (CONFIGURATION_ELEMENT.equals(child.getLocalName()) && SCHEMA_NAMESPACE.equals(child.getNamespaceURI())) { configuration = unmarshall(child); } } final String rulesRef = element.getAttribute(CONFIGURATION_REF_ATTRIBUTE); if (hasText(rulesRef)) { if (configuration != null) { throw new IllegalArgumentException("The " + CONFIGURATION_ELEMENT + " element and " + CONFIGURATION_REF_ATTRIBUTE + " attribute could not be used at the same time."); } bean.addPropertyReference("configuration", rulesRef); } else { bean.addPropertyValue("configuration", configuration); } }
From source file:org.xmatthew.spy2servers.component.config.ActiveMQJmxSpyComponentParser.java
protected void doParse(Element element, BeanDefinitionBuilder builder) { super.doParse(element, builder); Set destinationNames = null;//from w w w .ja va2 s. c om Set llegalIps = 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 (DESTINATION_NAMES_TO_WATCH_PROPERTY.equals(localName)) { destinationNames = IntegrationNamespaceUtils.parseDestinationNamesToWatch((Element) child); } else if (LLEGAL_IP_PROPERTY.equals(localName)) { llegalIps = IntegrationNamespaceUtils.parseLegalIps((Element) child); } } } if (destinationNames != null) { builder.addPropertyValue(DESTINATION_NAMES_TO_WATCH_PROPERTY, destinationNames); } if (llegalIps != null) { builder.addPropertyValue(LLEGAL_IP_PROPERTY, llegalIps); } builder.setScope(BeanDefinition.SCOPE_SINGLETON); }
From source file:org.xmatthew.spy2servers.component.config.EmailAlertComponentParser.java
protected void doParse(Element element, BeanDefinitionBuilder builder) { super.doParse(element, builder); EmailAccount emailAccount = null;/*w w w . j a v a 2s. com*/ Set emails = 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 (EMAIL_ACCOUNT_PROPERTY.equals(localName)) { emailAccount = IntegrationNamespaceUtils.parseEmailAccount((Element) child); } else if (EMAILS_PROPERTY.equals(localName)) { emails = IntegrationNamespaceUtils.parseEmails((Element) child); } } } if (emails != null) { builder.addPropertyValue(EMAILS_PROPERTY, emails); } if (emailAccount == null) { throw new RuntimeException("emailAccount must set in beans defination <emailAlert />"); } builder.addPropertyValue(EMAIL_ACCOUNT_PROPERTY, emailAccount); builder.setScope(BeanDefinition.SCOPE_SINGLETON); }
From source file:com.clican.pluto.dataprocess.spring.parser.ParamProcessorParser.java
@SuppressWarnings("unchecked") public void customiseBeanDefinition(BeanDefinition beanDef, Element element, ParserContext parserContext) { List paramBeanList = new ManagedList(); NodeList nodeList = element.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { String localName = node.getLocalName(); if ("param".equals(localName)) { RootBeanDefinition bean = new RootBeanDefinition(); bean.setAbstract(false); bean.setBeanClass(ParamBean.class); bean.setLazyInit(false); bean.setAutowireMode(Autowire.BY_NAME.value()); Element paramElement = (Element) node; String paramName = paramElement.getAttribute("paramName"); String paramValue = paramElement.getAttribute("paramValue"); String type = paramElement.getAttribute("type"); String override = paramElement.getAttribute("override"); String pattern = paramElement.getAttribute("pattern"); bean.getPropertyValues().addPropertyValue("paramName", paramName); bean.getPropertyValues().addPropertyValue("paramValue", paramValue); bean.getPropertyValues().addPropertyValue("type", type); bean.getPropertyValues().addPropertyValue("pattern", pattern); if (StringUtils.isNotEmpty(override)) { RootBeanDefinition over = new RootBeanDefinition(); over.setAbstract(false); over.setBeanClass(Boolean.class); over.setLazyInit(false); over.getConstructorArgumentValues().addIndexedArgumentValue(0, override); bean.getPropertyValues().addPropertyValue("override", over); }//w w w.ja v a 2 s . co m paramBeanList.add(bean); } } } beanDef.getPropertyValues().addPropertyValue("paramBeanList", paramBeanList); }
From source file:fr.acxio.tools.agia.alfresco.configuration.FolderDefinitionParser.java
protected AbstractBeanDefinition parseFolderElement(Element sElement, ParserContext sParserContext, BeanDefinitionBuilder sBuilder) { ManagedList<BeanDefinition> aChildren = new ManagedList<BeanDefinition>(); ManagedList<BeanDefinition> aDocuments = new ManagedList<BeanDefinition>(); sBuilder.addPropertyValue("parent", parseFolder(sElement)); NodeList children = sElement.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node node = children.item(i); if (node instanceof Element) { String nodeName = node.getLocalName(); Element child = (Element) node; if (nodeName.equals(NODEDEF_PROPERTIES)) { sBuilder.addPropertyValue("propertiesDefinitions", parseProperties(child, sParserContext)); } else if (nodeName.equals(NODEDEF_ASPECTS)) { sBuilder.addPropertyValue("aspectsDefinitions", parseAspects(child)); } else if (nodeName.equals(NODEDEF_ASSOCIATIONS)) { sBuilder.addPropertyValue("associationsDefinitions", parseAssociations(child)); } else if (nodeName.equals(NODEDEF_FOLDER)) { aChildren.add(parseFolderElement(child, sParserContext, BeanDefinitionBuilder.rootBeanDefinition(FolderDefinitionFactoryBean.class))); } else if (nodeName.equals(NODEDEF_DOCUMENT)) { DocumentDefinitionParser aDocumentDefinitionParser = new DocumentDefinitionParser(); aDocuments.add(aDocumentDefinitionParser.parse(child, sParserContext)); }/*from w w w. j a va 2 s .co m*/ } } sBuilder.addPropertyValue("children", aChildren); sBuilder.addPropertyValue("documents", aDocuments); return sBuilder.getBeanDefinition(); }