List of usage examples for org.jdom2 Element getChildren
public List<Element> getChildren(final String cname, final Namespace ns)
List
of all the child elements nested directly (one level deep) within this element with the given local name and belonging to the given Namespace, returned as Element
objects. From source file:de.smartics.maven.plugin.jboss.modules.parser.ModulesDescriptorBuilderV2.java
License:Apache License
private void parseApplyToDependencies(final Element applyToDependenciesElement) { if (applyToDependenciesElement == null) { return;//from w w w. jav a 2 s.co m } final ApplyToDependencies.Builder builder = new ApplyToDependencies.Builder(); final List<Element> dependenciesElements = applyToDependenciesElement.getChildren("apply-to-dependencies", NS); for (final Element dependenciesElement : dependenciesElements) { final Builder dependencyBuilder = new Builder(); parseMatcher(dependencyBuilder, dependenciesElement); parseApply(dependencyBuilder, dependenciesElement); final DependenciesDescriptor dependencies = dependencyBuilder.build(); builder.add(dependencies); } final ApplyToDependencies applyToDependencies = builder.build(); this.builder.with(applyToDependencies); }
From source file:de.sub.goobi.helper.HelperSchritte.java
License:Open Source License
public static void extractMetadata(Path metadataFile, Map<String, List<String>> metadataPairs) { SAXBuilder builder = new SAXBuilder(); Document doc;//from w ww.j a v a 2 s. c o m try { doc = builder.build(metadataFile.toString()); } catch (JDOMException | IOException e1) { return; } Element root = doc.getRootElement(); try { Element goobi = root.getChildren("dmdSec", mets).get(0).getChild("mdWrap", mets) .getChild("xmlData", mets).getChild("mods", mods).getChild("extension", mods) .getChild("goobi", goobiNamespace); List<Element> metadataList = goobi.getChildren(); addMetadata(metadataList, metadataPairs); for (Element el : root.getChildren("dmdSec", mets)) { if (el.getAttributeValue("ID").equals("DMDPHYS_0000")) { Element phys = el.getChild("mdWrap", mets).getChild("xmlData", mets).getChild("mods", mods) .getChild("extension", mods).getChild("goobi", goobiNamespace); List<Element> physList = phys.getChildren(); addMetadata(physList, metadataPairs); } } // create field for "DocStruct" String docType = root.getChildren("structMap", mets).get(0).getChild("div", mets) .getAttributeValue("TYPE"); metadataPairs.put("DocStruct", Collections.singletonList(docType)); } catch (Exception e) { logger.error(e); logger.error("Cannot extract metadata from " + metadataFile.toString()); } }
From source file:de.uniwuerzburg.info3.ofcprobe.vswitch.graphml.GraphmlParser.java
License:Open Source License
/** * Constructor// w w w.j a v a 2 s . c om * * @param graphml_filename the GraphML Filenam */ public GraphmlParser(String graphml_filename) { try { Document doc = new SAXBuilder().build(graphml_filename); Element graphml = doc.getRootElement(); this.ns = graphml.getNamespace(); this.graph = graphml.getChild("graph", this.ns); List<Element> list = graphml.getChildren("key", ns); for (Element e : list) { String s = e.getAttributeValue("attr.name"); switch (s) { case "Latitude": latitude_key = e.getAttributeValue("id"); break; case "Country": country_key = e.getAttributeValue("id"); break; case "Internal": internal_key = e.getAttributeValue("id"); break; case "id": if (e.getAttributeValue("for").equals("node")) { id_key = e.getAttributeValue("id"); } break; case "Longitude": longitude_key = e.getAttributeValue("id"); break; case "label": if (e.getAttributeValue("for").equals("node")) { label_key = e.getAttributeValue("id"); } break; case "LinkLabel": linklabel_key = e.getAttributeValue("id"); break; default: break; } } } catch (JDOMException | IOException e) { logger.error("Error in GraphmlParser"); System.exit(-1); } }