List of usage examples for org.w3c.dom Attr getNodeName
public String getNodeName();
From source file:ucar.unidata.idv.ui.ImageGenerator.java
/** * process the given node// www . java 2s . co m * * @param node Node to process * @param procNode The procedure node * * @return keep going * * @throws Throwable On badness */ protected boolean processTagCall(Element node, Element procNode) throws Throwable { if (procNode == null) { return error("Could not find procedure node for call:" + XmlUtil.toString(node)); } pushProperties(); String cdata = XmlUtil.getChildText(node); if ((cdata != null) && (cdata.trim().length() > 0)) { putProperty("paramtext", cdata); } else { putProperty("paramtext", ""); } NamedNodeMap procnnm = procNode.getAttributes(); if (procnnm != null) { for (int i = 0; i < procnnm.getLength(); i++) { Attr attr = (Attr) procnnm.item(i); if (!ATTR_NAME.equals(attr.getNodeName())) { putProperty(attr.getNodeName(), applyMacros(attr.getNodeValue())); } } } NamedNodeMap nnm = node.getAttributes(); if (nnm != null) { for (int i = 0; i < nnm.getLength(); i++) { Attr attr = (Attr) nnm.item(i); if (!ATTR_NAME.equals(attr.getNodeName())) { putProperty(attr.getNodeName(), applyMacros(attr.getNodeValue())); } } } try { if (!processChildren(node)) { return false; } try { if (!processChildren(procNode)) { return false; } } catch (MyReturnException mre) { //noop } } catch (Throwable throwable) { popProperties(); throw throwable; } popProperties(); return true; }
From source file:ucar.unidata.idv.ui.ImageGenerator.java
/** * process the given node/*from w w w.j a v a 2 s .c om*/ * * @param node Node to process * * @return keep going * * @throws Throwable On badness */ protected boolean processTagForeach(Element node) throws Throwable { pushProperties(); List allValues = new ArrayList(); int numElements = 0; int cnt = 1; NamedNodeMap attrs = node.getAttributes(); if (attrs == null) { return error("No values in foreach tag"); } for (int i = 0; i < attrs.getLength(); i++) { Attr attr = (Attr) attrs.item(i); String var = attr.getNodeName(); String values = applyMacros(attr.getNodeValue()); List tokens; //Check if it starts with file:, if so read the contents and split on new line if (values.startsWith("file:")) { String filename = applyMacros(values.substring("file:".length())); values = IOUtil.readContents(filename, getClass()).trim(); tokens = StringUtil.split(values, "\n"); } else { tokens = StringUtil.split(values, ","); } if (allValues.size() == 0) { numElements = tokens.size(); } else if (numElements != tokens.size()) { return error("Bad number of tokens (" + tokens.size() + " should be:" + numElements + ") in foreach argument:\n" + var + "=" + tokens); } allValues.add(new Object[] { var, tokens }); cnt++; } for (int tokIdx = 0; tokIdx < numElements; tokIdx++) { for (int valueIdx = 0; valueIdx < allValues.size(); valueIdx++) { Object[] tuple = (Object[]) allValues.get(valueIdx); putProperty(tuple[0], ((List) tuple[1]).get(tokIdx)); } try { if (!processChildren(node)) { return false; } } catch (MyBreakException be) { break; } catch (MyContinueException ce) { } } popProperties(); return true; }