List of usage examples for org.jdom2 Document getRootElement
public Element getRootElement()
Element
for this Document
From source file:dblp.xml.DBLPParserSecondSchema.java
public static void parse() { createDir("data/" + outputDir); DBLPParserSecondSchema parser = new DBLPParserSecondSchema(); try {/* ww w. jav a 2 s . co m*/ title_author_writer = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(title_author_path), "utf-8")); author_conf_writer = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(author_conf_path), "utf-8")); title_year_writer = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(title_year_path), "utf-8")); conf_year_writer = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(conf_year_path), "utf-8")); SAXBuilder builder = new SAXBuilder(); String path = "data/dblp.xml"; Document jdomDocument = builder.build(path); Element root = jdomDocument.getRootElement(); // List<String> types = Arrays.asList("incollection", "article", "inproceedings", "proceedings"); List<String> types = Arrays.asList("inproceedings"); for (String type : types) { parser.extractElements(root, type); } titlesCollection.writeToFile(title_path); authorsCollection.writeToFile(author_path); confsCollection.writeToFile(conf_path); yearConfsCollection.writeToFile(year_with_conf_path); yearConfsCollection.writeToFileJustFirsToken(year_path); } catch (Exception e) { e.printStackTrace(); } }
From source file:dblp.xml.DBLPParserThirdSchema.java
public static void parse() { createDir("data/" + outputDir); DBLPParserThirdSchema parser = new DBLPParserThirdSchema(); try {/* ww w . j a va2 s . com*/ title_author_writer = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(title_author_path), "utf-8")); title_conf_writer = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(title_conf_path), "utf-8")); conf_year_writer = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(conf_year_path), "utf-8")); SAXBuilder builder = new SAXBuilder(); String path = "data/dblp.xml"; Document jdomDocument = builder.build(path); Element root = jdomDocument.getRootElement(); // List<String> types = Arrays.asList("incollection", "article", "inproceedings", "proceedings"); List<String> types = Arrays.asList("inproceedings"); for (String type : types) { parser.extractElements(root, type); } titlesCollection.writeToFile(title_path); authorsCollection.writeToFile(author_path); confsCollection.writeToFile(conf_path); yearConfsCollection.writeToFile(year_with_conf_path); yearConfsCollection.writeToFileJustFirsToken(year_path); } catch (Exception e) { e.printStackTrace(); } }
From source file:DBWorkers.DBFiller.java
/** * HashMap Xml//ww w . ja v a 2s .c o m * @param xml * @return Hash map Xml */ protected HashMap<String, Object> parsePersonXML(String xml) { HashMap<String, Object> personData = new HashMap<String, Object>(); try { SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(new InputSource(new StringReader(xml))); Element root = doc.getRootElement(); Element user = root.getChild("user"); personData.put("uid", getOneField("uid", user)); personData.put("first_name", getOneField("first_name", user)); personData.put("last_name", getOneField("last_name", user)); personData.put("sex", getOneField("sex", user)); personData.put("bdate", getOneField("bdate", user)); personData.put("city", getOneField("city", user)); personData.put("can_post", getOneField("can_post", user)); personData.put("status", getOneField("status", user)); personData.put("relation", getOneField("relation", user)); personData.put("nickname", getOneField("nickname", user)); personData.put("interests", getOneField("interests", user)); personData.put("movies", getOneField("movies", user)); personData.put("tv", getOneField("tv", user)); personData.put("books", getOneField("books", user)); personData.put("games", getOneField("games", user)); personData.put("about", getOneField("about", user)); personData.put("counters", getOneField("counters", user)); } catch (JDOMException ex) { Logger.getLogger(DBCreator.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(DBCreator.class.getName()).log(Level.SEVERE, null, ex); } return personData; }
From source file:de.altimos.util.asset.ext.XmlDocument.java
License:Apache License
@SuppressWarnings("rawtypes") public XmlDocument(AssetKey key, Document doc) { super();// w w w.j a va 2s . co m if (doc != null) { setDocType(doc.getDocType()); setBaseURI(doc.getBaseURI()); setContent(doc.getRootElement().detach()); } this.key = key; }
From source file:de.andrena.tools.macker.rule.RuleSetBuilder.java
License:Open Source License
public Collection<RuleSet> build(final Document doc) throws RulesException { return build(doc.getRootElement()); }
From source file:de.bund.bfr.knime.pmm.common.PmmXmlDoc.java
License:Open Source License
public PmmXmlDoc(String xmlString) throws IOException, JDOMException { this();/* w ww . j a va 2s . com*/ SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(new StringReader(xmlString)); Element rootElement = doc.getRootElement(); parseElement(rootElement); }
From source file:de.bund.bfr.knime.pmm.extendedtable.Model1Metadata.java
License:Open Source License
public Model1Metadata(String xmlString) throws IOException, JDOMException { this();//from w w w . ja va2 s. c om SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(new StringReader(xmlString)); Element rootElement = doc.getRootElement(); parseElement(rootElement); }
From source file:de.bund.bfr.knime.pmm.extendedtable.Model2Metadata.java
License:Open Source License
public Model2Metadata(String xmlString) throws IOException, JDOMException { this();//from w ww. j av a 2 s .c o m SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(new StringReader(xmlString)); Element rootElement = doc.getRootElement(); parseElement(rootElement); }
From source file:de.bund.bfr.knime.pmm.extendedtable.TimeSeriesMetadata.java
License:Open Source License
public TimeSeriesMetadata(String xmlString) throws IOException, JDOMException { this();/*ww w . ja v a 2 s .c o m*/ SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(new StringReader(xmlString)); Element rootElement = doc.getRootElement(); parseElement(rootElement); }
From source file:de.danielluedecke.zettelkasten.database.Bookmarks.java
License:Open Source License
/** * /*from w w w .java 2s . c om*/ * @param dataObj * @param newbookmarks */ public void appendBookmarks(Daten dataObj, Document newbookmarks) { // create a list of all elements from the given xml file try { List<?> elementList = newbookmarks.getRootElement().getContent(); try { // iterate all importet bookmakrs for (int cnt = 0; cnt < newbookmarks.getContentSize(); cnt++) { // retrieve each single bookmark-element Element b = (Element) elementList.get(cnt); // get bookmark-id (i.e. unique entry-ID) String id = b.getAttributeValue("id"); // check for valid value if (id != null && !id.isEmpty()) { // find entry number from ID int index = dataObj.findZettelFromID(id); // check for valid return parameter if (index != -1) { // we now have the entry's number. now retrieve // bookmark-category String cat = b.getAttributeValue("cat"); // check for valid value if (cat != null && !cat.isEmpty()) { // retrieve possible comment String comment = b.getText(); // and add new importet bookmark addBookmark(index, cat, comment); } } } } } catch (IndexOutOfBoundsException e) { } } catch (IllegalStateException e) { Constants.zknlogger.log(Level.WARNING, e.getLocalizedMessage()); } }