List of usage examples for org.w3c.dom Element getNodeName
public String getNodeName();
From source file:com.espertech.esper.client.ConfigurationParser.java
private static List<String> getHandlerFactories(Element parentElement) { List<String> list = new ArrayList<String>(); DOMElementIterator nodeIterator = new DOMElementIterator(parentElement.getChildNodes()); while (nodeIterator.hasNext()) { Element subElement = nodeIterator.next(); if (subElement.getNodeName().equals("handlerFactory")) { String text = getRequiredAttribute(subElement, "class"); list.add(text);//from w w w.ja v a 2s .com } } return list; }
From source file:importer.handler.post.stages.Splitter.java
/** * Percolate the versions accumulated in root to suitable sub-elements * @param elem the start node with its versions to percolate *//*w w w . j av a2s . co m*/ private void percolateDown(Element elem) { Node parent = elem.getParentNode(); if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE) { System.out.println(elem.getNodeName()); String vers = ((Element) parent).getAttribute(VERSIONS); if (vers != null && vers.length() > 0) { if (!discriminator.isSibling(elem)) { Discriminator.addVersion(elem, vers); addDoneTag(elem); } else if (elem.hasAttribute(FINAL)) { String fVers = elem.getAttribute(FINAL); if (fVers != null && fVers.length() > 0) { // find inverse versions HashSet<String> invVers = new HashSet<String>(); String[] parts = vers.split(" "); String[] iparts = fVers.split(" "); for (int i = 0; i < parts.length; i++) if ( /*!parts[i].startsWith(DEL) &&*/ !parts[i].equals(BASE)) invVers.add(parts[i]); for (int i = 0; i < iparts.length; i++) if (invVers.contains(iparts[i])) invVers.remove(iparts[i]); String newVers = hashsetToString(invVers); Discriminator.addVersion(elem, newVers); addDoneTag(elem); Element lastOChild = discriminator.lastOpenChild(elem); while (lastOChild != null) { Discriminator.addVersion(lastOChild, newVers); lastOChild = discriminator.lastOpenChild(lastOChild); } } } // else ignore it } } // now examine the children of elem Element child = Discriminator.firstChild(elem); while (child != null && !isDone(child)) { percolateDown(child); child = Discriminator.firstChild(child); } // finall the siblings of elem Element brother = Discriminator.nextSibling(elem, true); while (brother != null) { if (!isDone(brother)) percolateDown(brother); brother = Discriminator.nextSibling(brother, true); } }
From source file:com.espertech.esper.client.ConfigurationParser.java
private static Properties handleProperties(Element element, String propElementName) { Properties properties = new Properties(); DOMElementIterator nodeIterator = new DOMElementIterator(element.getChildNodes()); while (nodeIterator.hasNext()) { Element subElement = nodeIterator.next(); if (subElement.getNodeName().equals(propElementName)) { String name = getRequiredAttribute(subElement, "name"); String value = getRequiredAttribute(subElement, "value"); properties.put(name, value); }//from w ww . ja v a 2 s . c om } return properties; }
From source file:com.legstar.codegen.CodeGenMake.java
/** * Template elements might have children. These are used to pass additional * parameters to the template generation process. * Children are expected to have a single value attribute otherwise, they * are ignored.//from w w w .ja v a 2 s . co m * * @param templateEl the current template element * @return a Map of parameters/values */ private Map<String, Object> getParameters(final Element templateEl) { Map<String, Object> parameters = new HashMap<String, Object>(); NodeList childs = templateEl.getChildNodes(); for (int i = 0; i < childs.getLength(); i++) { if (childs.item(i) instanceof Element) { Element parmEl = (Element) childs.item(i); String value = parmEl.getAttribute("value"); if (value != null) { parameters.put(parmEl.getNodeName(), value); } } } return parameters; }
From source file:net.sourceforge.dita4publishers.impl.dita.DitaIdTargetImpl.java
/** * @param containingDoc//from w ww. j ava 2 s .com * @param targetElem */ public DitaIdTargetImpl(Document containingDoc, Element targetElem) { this.containingDoc = containingDoc; this.targetElem = targetElem; this.id = targetElem.getAttribute("id"); try { this.ditaClass = new DitaClassImpl(targetElem.getAttribute("class")); } catch (DitaClassSpecificationException e) { log.warn("Problem with DITA class specification for element \"" + targetElem.getNodeName() + "\": " + e.getMessage() + "\n" + " Processing of this target may be incorrect."); } }
From source file:com.enonic.esl.xml.XMLTool.java
public static int getElementIndex(Element elem) { Element[] elems = XMLTool.getElements((Element) elem.getParentNode(), elem.getNodeName()); for (int i = 0; i < elems.length; i++) { if (elems[i] == elem) { return i; }/*from w ww. jav a2 s. c om*/ } return 0; }
From source file:com.espertech.esper.client.ConfigurationParser.java
private static void handleDefaultsViewResources(Configuration configuration, Element parentElement) { DOMElementIterator nodeIterator = new DOMElementIterator(parentElement.getChildNodes()); while (nodeIterator.hasNext()) { Element subElement = nodeIterator.next(); if (subElement.getNodeName().equals("share-views")) { String valueText = getRequiredAttribute(subElement, "enabled"); Boolean value = Boolean.parseBoolean(valueText); configuration.getEngineDefaults().getViewResources().setShareViews(value); }/*from w w w.j av a2 s .c o m*/ if (subElement.getNodeName().equals("allow-multiple-expiry-policy")) { String valueText = getRequiredAttribute(subElement, "enabled"); Boolean value = Boolean.parseBoolean(valueText); configuration.getEngineDefaults().getViewResources().setAllowMultipleExpiryPolicies(value); } } }
From source file:com.espertech.esper.client.ConfigurationParser.java
private static void handleDefaultsPatterns(Configuration configuration, Element parentElement) { DOMElementIterator nodeIterator = new DOMElementIterator(parentElement.getChildNodes()); while (nodeIterator.hasNext()) { Element subElement = nodeIterator.next(); if (subElement.getNodeName().equals("max-subexpression")) { String valueText = getRequiredAttribute(subElement, "value"); Long value = Long.parseLong(valueText); configuration.getEngineDefaults().getPatterns().setMaxSubexpressions(value); String preventText = getOptionalAttribute(subElement, "prevent-start"); if (preventText != null) { configuration.getEngineDefaults().getPatterns() .setMaxSubexpressionPreventStart(Boolean.parseBoolean(preventText)); }/*from w w w . j a va2 s .c om*/ } } }
From source file:com.espertech.esper.client.ConfigurationParser.java
private static void handlePlugIneventTypeNameResolution(Configuration configuration, Element element) { DOMElementIterator nodeIterator = new DOMElementIterator(element.getChildNodes()); List<URI> uris = new ArrayList<URI>(); while (nodeIterator.hasNext()) { Element subElement = nodeIterator.next(); if (subElement.getNodeName().equals("resolution-uri")) { String uriValue = getRequiredAttribute(subElement, "value"); URI uri;//from w w w . java2 s . c o m try { uri = new URI(uriValue); } catch (URISyntaxException ex) { throw new ConfigurationException("Error parsing URI '" + uriValue + "' as a valid java.net.URI string:" + ex.getMessage(), ex); } uris.add(uri); } } configuration.setPlugInEventTypeResolutionURIs(uris.toArray(new URI[uris.size()])); }
From source file:com.nridge.core.base.io.xml.DocumentOpXML.java
/** * Parses an XML DOM element and loads it into a document list. * * @param anElement DOM element./*from w ww.java 2s .co m*/ * @throws java.io.IOException I/O related exception. */ @Override public void load(Element anElement) throws IOException { String nodeName = anElement.getNodeName(); if (StringUtils.equalsIgnoreCase(nodeName, IO.XML_OPERATION_NODE_NAME)) loadOperation(anElement); }