@Test public void testExtractNLM() throws Exception { System.out.println("extractNLM"); SAXBuilder builder = new SAXBuilder(); Document nlm = builder.build(this.getClass().getResourceAsStream("/sampleNlm.xml")); ArticleMeta result = ArticleMeta.extractNLM(nlm); assertEquals("Association des Annales de l’institut Fourier", result.getPublisher()); assertEquals("Annales de l’institut Fourier",result.getJournalTitle()); assertEquals("Analytic inversion of adjunction: blabla extension theorems with gain", result.getTitle()); assertEquals("10.1016/j.lisr.2011.06.002", result.getDoi()); assertEquals("Some abstract text...", result.getAbstractText()); assertEquals("703", result.getFpage()); assertEquals("718", result.getLpage()); assertEquals("57", result.getVolume()); assertEquals("3", result.getIssue()); assertEquals("2007", result.getPubDate()); assertEquals("2005-07-25", result.getReceivedDate()); assertEquals("2006-02-20", result.getAcceptedDate()); assertEquals(2, result.getAuthors().size()); assertTrue(result.getAuthors().get(0).getName().contains("McNeal")); assertTrue(result.getAuthors().get(0).getName().contains("Jeffery D.")); assertTrue(result.getKeywords().contains("32Q99")); assertTrue(result.getKeywords().contains("denominators")); assertEquals(8, result.getKeywords().size()); }
public static ArticleMeta extractNLM(Document nlm) { log.debug("Starting extraction from document..."); try { ArticleMeta res = new ArticleMeta(); res.setJournalTitle(extractXPathValue(nlm, "/article/front log.debug("Got journal title: " + res.getJournalTitle()); res.setJournalISSN(extractXPathValue(nlm, "/article/front log.debug("Got journal ISSN: " + res.getJournalISSN()); res.setPublisher(extractXPathValue(nlm, "/article/front log.debug("Got publisher name: " + res.getPublisher()); res.setTitle(extractXPathValue(nlm, "/article/front log.debug("Got title from xpath: " + res.getTitle()); res.setDoi(extractXPathValue(nlm, "/article/front log.debug("Got doi from xpath: " + res.getDoi()); res.setUrn(extractXPathValue(nlm, "/article/front log.debug("Got urn: " + res.getUrn()); res.setAbstractText(extractXPathValue(nlm, "/article/front log.debug("Got abstract: " + res.getAbstractText()); res.setFpage(extractXPathValue(nlm, "/article/front/article-meta/fpage")); res.setLpage(extractXPathValue(nlm, "/article/front/article-meta/lpage")); res.setVolume(extractXPathValue(nlm, "/article/front/article-meta/volume")); res.setIssue(extractXPathValue(nlm, "/article/front/article-meta/issue")); Map<String, String> affiliations = extractAffiliations(nlm, " res.setAuthors(extractContributorMeta(nlm, " res.setEditors(extractContributorMeta(nlm, " res.setPubDate(extractDateValue(nlm, " res.setReceivedDate(extractDateValue(nlm, " res.setRevisedDate(extractDateValue(nlm, " res.setAcceptedDate(extractDateValue(nlm, " XPath xPath = XPath.newInstance(" List<String> kwds = new ArrayList<String>(); for (Object e : xPath.selectNodes(nlm)) { kwds.add(((Element) e).getTextTrim()); } res.setKeywords(kwds); res.setReferences(extractReferences(nlm, " return res; } catch (JDOMException ex) { log.error("Unexpected exception while working with xpath", ex); throw new RuntimeException(ex); } }
ArticleMeta { public static ArticleMeta extractNLM(Document nlm) { log.debug("Starting extraction from document..."); try { ArticleMeta res = new ArticleMeta(); res.setJournalTitle(extractXPathValue(nlm, "/article/front log.debug("Got journal title: " + res.getJournalTitle()); res.setJournalISSN(extractXPathValue(nlm, "/article/front log.debug("Got journal ISSN: " + res.getJournalISSN()); res.setPublisher(extractXPathValue(nlm, "/article/front log.debug("Got publisher name: " + res.getPublisher()); res.setTitle(extractXPathValue(nlm, "/article/front log.debug("Got title from xpath: " + res.getTitle()); res.setDoi(extractXPathValue(nlm, "/article/front log.debug("Got doi from xpath: " + res.getDoi()); res.setUrn(extractXPathValue(nlm, "/article/front log.debug("Got urn: " + res.getUrn()); res.setAbstractText(extractXPathValue(nlm, "/article/front log.debug("Got abstract: " + res.getAbstractText()); res.setFpage(extractXPathValue(nlm, "/article/front/article-meta/fpage")); res.setLpage(extractXPathValue(nlm, "/article/front/article-meta/lpage")); res.setVolume(extractXPathValue(nlm, "/article/front/article-meta/volume")); res.setIssue(extractXPathValue(nlm, "/article/front/article-meta/issue")); Map<String, String> affiliations = extractAffiliations(nlm, " res.setAuthors(extractContributorMeta(nlm, " res.setEditors(extractContributorMeta(nlm, " res.setPubDate(extractDateValue(nlm, " res.setReceivedDate(extractDateValue(nlm, " res.setRevisedDate(extractDateValue(nlm, " res.setAcceptedDate(extractDateValue(nlm, " XPath xPath = XPath.newInstance(" List<String> kwds = new ArrayList<String>(); for (Object e : xPath.selectNodes(nlm)) { kwds.add(((Element) e).getTextTrim()); } res.setKeywords(kwds); res.setReferences(extractReferences(nlm, " return res; } catch (JDOMException ex) { log.error("Unexpected exception while working with xpath", ex); throw new RuntimeException(ex); } } }
ArticleMeta { public static ArticleMeta extractNLM(Document nlm) { log.debug("Starting extraction from document..."); try { ArticleMeta res = new ArticleMeta(); res.setJournalTitle(extractXPathValue(nlm, "/article/front log.debug("Got journal title: " + res.getJournalTitle()); res.setJournalISSN(extractXPathValue(nlm, "/article/front log.debug("Got journal ISSN: " + res.getJournalISSN()); res.setPublisher(extractXPathValue(nlm, "/article/front log.debug("Got publisher name: " + res.getPublisher()); res.setTitle(extractXPathValue(nlm, "/article/front log.debug("Got title from xpath: " + res.getTitle()); res.setDoi(extractXPathValue(nlm, "/article/front log.debug("Got doi from xpath: " + res.getDoi()); res.setUrn(extractXPathValue(nlm, "/article/front log.debug("Got urn: " + res.getUrn()); res.setAbstractText(extractXPathValue(nlm, "/article/front log.debug("Got abstract: " + res.getAbstractText()); res.setFpage(extractXPathValue(nlm, "/article/front/article-meta/fpage")); res.setLpage(extractXPathValue(nlm, "/article/front/article-meta/lpage")); res.setVolume(extractXPathValue(nlm, "/article/front/article-meta/volume")); res.setIssue(extractXPathValue(nlm, "/article/front/article-meta/issue")); Map<String, String> affiliations = extractAffiliations(nlm, " res.setAuthors(extractContributorMeta(nlm, " res.setEditors(extractContributorMeta(nlm, " res.setPubDate(extractDateValue(nlm, " res.setReceivedDate(extractDateValue(nlm, " res.setRevisedDate(extractDateValue(nlm, " res.setAcceptedDate(extractDateValue(nlm, " XPath xPath = XPath.newInstance(" List<String> kwds = new ArrayList<String>(); for (Object e : xPath.selectNodes(nlm)) { kwds.add(((Element) e).getTextTrim()); } res.setKeywords(kwds); res.setReferences(extractReferences(nlm, " return res; } catch (JDOMException ex) { log.error("Unexpected exception while working with xpath", ex); throw new RuntimeException(ex); } }  }
ArticleMeta { public static ArticleMeta extractNLM(Document nlm) { log.debug("Starting extraction from document..."); try { ArticleMeta res = new ArticleMeta(); res.setJournalTitle(extractXPathValue(nlm, "/article/front log.debug("Got journal title: " + res.getJournalTitle()); res.setJournalISSN(extractXPathValue(nlm, "/article/front log.debug("Got journal ISSN: " + res.getJournalISSN()); res.setPublisher(extractXPathValue(nlm, "/article/front log.debug("Got publisher name: " + res.getPublisher()); res.setTitle(extractXPathValue(nlm, "/article/front log.debug("Got title from xpath: " + res.getTitle()); res.setDoi(extractXPathValue(nlm, "/article/front log.debug("Got doi from xpath: " + res.getDoi()); res.setUrn(extractXPathValue(nlm, "/article/front log.debug("Got urn: " + res.getUrn()); res.setAbstractText(extractXPathValue(nlm, "/article/front log.debug("Got abstract: " + res.getAbstractText()); res.setFpage(extractXPathValue(nlm, "/article/front/article-meta/fpage")); res.setLpage(extractXPathValue(nlm, "/article/front/article-meta/lpage")); res.setVolume(extractXPathValue(nlm, "/article/front/article-meta/volume")); res.setIssue(extractXPathValue(nlm, "/article/front/article-meta/issue")); Map<String, String> affiliations = extractAffiliations(nlm, " res.setAuthors(extractContributorMeta(nlm, " res.setEditors(extractContributorMeta(nlm, " res.setPubDate(extractDateValue(nlm, " res.setReceivedDate(extractDateValue(nlm, " res.setRevisedDate(extractDateValue(nlm, " res.setAcceptedDate(extractDateValue(nlm, " XPath xPath = XPath.newInstance(" List<String> kwds = new ArrayList<String>(); for (Object e : xPath.selectNodes(nlm)) { kwds.add(((Element) e).getTextTrim()); } res.setKeywords(kwds); res.setReferences(extractReferences(nlm, " return res; } catch (JDOMException ex) { log.error("Unexpected exception while working with xpath", ex); throw new RuntimeException(ex); } }  String getTitle(); void setTitle(String title); String getJournalTitle(); void setJournalTitle(String journalTitle); String getJournalISSN(); void setJournalISSN(String journalISSN); String getPublisher(); void setPublisher(String publisher); String getPublisherLoc(); void setPublisherLoc(String publisherLoc); String getDoi(); void setDoi(String doi); String getUrn(); void setUrn(String urn); String getAbstractText(); void setAbstractText(String abstractText); List<ContributorMeta> getAuthors(); void setAuthors(List<ContributorMeta> authors); List<ContributorMeta> getEditors(); void setEditors(List<ContributorMeta> editors); String getKeywordsString(); String getFpage(); void setFpage(String fpage); String getLpage(); void setLpage(String lpage); String getPages(); String getVolume(); void setVolume(String volume); String getIssue(); void setIssue(String issue); List<String> getKeywords(); void setKeywords(List<String> keywords); String getPubDate(); void setPubDate(String pubDate); String getReceivedDate(); void setReceivedDate(String receivedDate); String getRevisedDate(); void setRevisedDate(String revisedDate); String getAcceptedDate(); void setAcceptedDate(String acceptedDate); List<ArticleMeta> getReferences(); void setReferences(List<ArticleMeta> references); static ArticleMeta extractNLM(Document nlm); }
ArticleMeta { public static ArticleMeta extractNLM(Document nlm) { log.debug("Starting extraction from document..."); try { ArticleMeta res = new ArticleMeta(); res.setJournalTitle(extractXPathValue(nlm, "/article/front log.debug("Got journal title: " + res.getJournalTitle()); res.setJournalISSN(extractXPathValue(nlm, "/article/front log.debug("Got journal ISSN: " + res.getJournalISSN()); res.setPublisher(extractXPathValue(nlm, "/article/front log.debug("Got publisher name: " + res.getPublisher()); res.setTitle(extractXPathValue(nlm, "/article/front log.debug("Got title from xpath: " + res.getTitle()); res.setDoi(extractXPathValue(nlm, "/article/front log.debug("Got doi from xpath: " + res.getDoi()); res.setUrn(extractXPathValue(nlm, "/article/front log.debug("Got urn: " + res.getUrn()); res.setAbstractText(extractXPathValue(nlm, "/article/front log.debug("Got abstract: " + res.getAbstractText()); res.setFpage(extractXPathValue(nlm, "/article/front/article-meta/fpage")); res.setLpage(extractXPathValue(nlm, "/article/front/article-meta/lpage")); res.setVolume(extractXPathValue(nlm, "/article/front/article-meta/volume")); res.setIssue(extractXPathValue(nlm, "/article/front/article-meta/issue")); Map<String, String> affiliations = extractAffiliations(nlm, " res.setAuthors(extractContributorMeta(nlm, " res.setEditors(extractContributorMeta(nlm, " res.setPubDate(extractDateValue(nlm, " res.setReceivedDate(extractDateValue(nlm, " res.setRevisedDate(extractDateValue(nlm, " res.setAcceptedDate(extractDateValue(nlm, " XPath xPath = XPath.newInstance(" List<String> kwds = new ArrayList<String>(); for (Object e : xPath.selectNodes(nlm)) { kwds.add(((Element) e).getTextTrim()); } res.setKeywords(kwds); res.setReferences(extractReferences(nlm, " return res; } catch (JDOMException ex) { log.error("Unexpected exception while working with xpath", ex); throw new RuntimeException(ex); } }  String getTitle(); void setTitle(String title); String getJournalTitle(); void setJournalTitle(String journalTitle); String getJournalISSN(); void setJournalISSN(String journalISSN); String getPublisher(); void setPublisher(String publisher); String getPublisherLoc(); void setPublisherLoc(String publisherLoc); String getDoi(); void setDoi(String doi); String getUrn(); void setUrn(String urn); String getAbstractText(); void setAbstractText(String abstractText); List<ContributorMeta> getAuthors(); void setAuthors(List<ContributorMeta> authors); List<ContributorMeta> getEditors(); void setEditors(List<ContributorMeta> editors); String getKeywordsString(); String getFpage(); void setFpage(String fpage); String getLpage(); void setLpage(String lpage); String getPages(); String getVolume(); void setVolume(String volume); String getIssue(); void setIssue(String issue); List<String> getKeywords(); void setKeywords(List<String> keywords); String getPubDate(); void setPubDate(String pubDate); String getReceivedDate(); void setReceivedDate(String receivedDate); String getRevisedDate(); void setRevisedDate(String revisedDate); String getAcceptedDate(); void setAcceptedDate(String acceptedDate); List<ArticleMeta> getReferences(); void setReferences(List<ArticleMeta> references); static ArticleMeta extractNLM(Document nlm);  }