/* * If the element contains an attribute 'makeOnly' with a value of 'true', * create a child element before any existing children which will display a node * which will display only the elements records. * Compute the query attribute, which is the appended result of all of the children * appended to this element name. If noQuery=true. then do not generate a query term * for this element. */ String computeQuery(Element e) { String query = ""; if (!(e.getAttribute("noQuery").equalsIgnoreCase("true"))) { query = e.getAttribute("name"); } String makeOnly = e.getAttribute("makeOnly"); boolean madeOnly = false; NodeList children = e.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { if (makeOnly.equalsIgnoreCase("true") && !madeOnly) { // need to make an ...-Only node and populate it String onlyTagName = e.getTagName() + "-Only"; Element only = ((Document) dom.getNode()).createElement(onlyTagName); only.setAttribute("name", e.getAttribute("name") + "-Only"); only.setAttribute("query", e.getAttribute("name")); e.insertBefore(only, child); i++; madeOnly = true; } if (query.length() > 0) { query += ","; } query += computeQuery((Element) child); } } log.info("setting query for " + e.getNodeName() + " " + query); e.setAttribute("query", query); return query; }