List of usage examples for org.jdom2 Element getParentElement
final public Element getParentElement()
From source file:ru.iteco.xmldoc.Scope.java
License:Open Source License
public Scope(Element element) { Element scopeEl = element.getParentElement(); if (scopeEl.getName() != "scope") System.out.println("Where is scope ? Parent el :" + scopeEl.getName()); else {// w ww . j a va2s . co m List<Attribute> scopes = scopeEl.getAttributes(); for (Attribute sc : scopes) { String tmp_val = sc.getValue(); String[] tmp_vals = tmp_val.split(","); for (String v : tmp_vals) { add(sc.getName(), v.trim()); } } } }
From source file:se.miun.itm.input.export.LaTeXFileExporter.java
License:Open Source License
private void appendMatrixRow(StringBuilder b, Element child, int depth, int rootDistance) { if (child.getAttributeValue(Q.VALUE_ATTR) == null) appendMatrixRow(b, child.getChildren().get(0), depth, rootDistance); else {/*ww w . j a va 2 s. c om*/ if (depth == 1) appendValueToTable(b, child, rootDistance); else { List<Element> values = child.getParentElement().getChildren(); for (int i = 0; i < values.size(); i++) { appendValueToTable(b, values.get(i), rootDistance); if (i < values.size() - 1) b.append('&'); } } } }
From source file:se.miun.itm.input.export.LaTeXFileExporter.java
License:Open Source License
private void appendParamId(StringBuilder b, Element param) { String paramId = param.getAttributeValue(Q.ID_ATTR); if (param.getParentElement().getName().equals(Q.SCHOICE)) { b.append("\\textit{"); b.append(param.getParentElement().getAttributeValue(Q.ID_ATTR)); b.append("}."); }// w w w .j av a 2 s .c o m b.append(paramId); }
From source file:se.miun.itm.input.model.param.Param.java
License:Open Source License
private void initFromOriginal(Element original) { // init attributes setNamespace(original.getNamespace()); setName(original.getName());/*from w ww.ja va 2 s . c o m*/ Attribute attr; for (Object content : original.getAttributes()) { attr = (Attribute) content; setAttribute(attr.getName(), attr.getValue()); } // move children Element childE; Object[] children = original.getChildren().toArray(); for (Object child : children) { childE = (Element) child; original.removeContent(childE); addContent(childE); } // attach to parent Element parent = original.getParentElement(); parent.removeContent(original); parent.addContent(this); }
From source file:se.miun.itm.input.model.param.ParamStore.java
License:Open Source License
private void initElementByType(String referentType, Element referent, Element type) { Element newChoice = type.clone(); String localId = referent.getAttributeValue(Q.ID_ATTR); addAlias(referent, type);// w w w.j a v a2 s .c o m newChoice.setAttribute(Q.ID_ATTR, localId); newChoice.setName(referentType); overrideSubElementsIfExist(referent, newChoice); Element parent = referent.getParentElement(); parent.removeContent(referent); parent.addContent(newChoice); }
From source file:se.miun.itm.input.util.ParamInitializer.java
License:Open Source License
private static Integer getRootDist(Element elem) { int counter = 0; while (!elem.isRootElement()) { elem = elem.getParentElement(); counter++;/* w w w. ja v a 2 s. co m*/ } return counter; }
From source file:se.miun.itm.input.util.ParamUtil.java
License:Open Source License
public static String deriveInputValueId(Element value) { Element parent = value.getParentElement(); String localId = value.getAttributeValue(Q.ID_ATTR); if (value.getName().equals(Q.SVALUE)) localId = value.getAttributeValue(Q.ID_ATTR) + "." + value.getAttributeValue(Q.VALUE_ATTR); return deriveInputValueId(parent, localId); }
From source file:se.miun.itm.input.util.ParamUtil.java
License:Open Source License
public static String deriveInputValueId(Element value, String localId) { if (value == null || value.isRootElement()) return localId; return deriveInputValueId(value.getParentElement()) + "." + localId; }
From source file:se.miun.itm.input.util.ParamUtil.java
License:Open Source License
private static Stack<String> createStack(Element element) { Stack<String> stack = new Stack<String>(); stack.push(element.getAttributeValue(Q.ID_ATTR)); Element current = element.getParentElement(); while (!current.isRootElement()) { stack.push(current.getAttributeValue(Q.VALUE_ATTR)); stack.push(current.getAttributeValue(Q.ID_ATTR)); current = current.getParentElement(); }//from ww w. jav a 2s. c o m return stack; }
From source file:se.miun.itm.input.util.ParamUtil.java
License:Open Source License
public static String getParentId(Param<?> param) { Element parent = param.getParentElement(); if (parent.isRootElement()) return ""; if (parent instanceof SChoice) return ((Param<?>) parent.getParentElement()).getId(); return ((Param<?>) parent).getId(); }