diff --git a/build.gradle b/build.gradle index 4b59567380c..26eae64014f 100644 --- a/build.gradle +++ b/build.gradle @@ -32,7 +32,7 @@ apply plugin: 'checkstyle' apply from: 'eclipse.gradle' apply from: 'localization.gradle' -apply from: 'medline.gradle' +apply from: 'xjc.gradle' group = "net.sf.jabref" version = "3.6dev" diff --git a/src/main/java/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporter.java b/src/main/java/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporter.java index 794da34d4d6..b2eb6393157 100644 --- a/src/main/java/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporter.java +++ b/src/main/java/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporter.java @@ -17,22 +17,34 @@ import java.io.BufferedReader; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.math.BigInteger; import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.regex.Pattern; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import javax.xml.datatype.XMLGregorianCalendar; +import net.sf.jabref.importer.fileformat.bibtexml.Entry; +import net.sf.jabref.importer.fileformat.bibtexml.File; +import net.sf.jabref.importer.fileformat.bibtexml.Inbook; +import net.sf.jabref.importer.fileformat.bibtexml.Incollection; import net.sf.jabref.logic.importer.ParserResult; -import net.sf.jabref.logic.importer.util.BibTeXMLHandler; import net.sf.jabref.logic.util.FileExtensions; import net.sf.jabref.model.entry.BibEntry; +import net.sf.jabref.model.entry.FieldName; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.xml.sax.InputSource; /** * Importer for the BibTeXML format. @@ -46,6 +58,10 @@ public class BibTeXMLImporter extends ImportFormat { private static final Pattern START_PATTERN = Pattern.compile("<(bibtex:)?file .*"); + private static final List IGNORED_METHODS = Arrays.asList("getClass", "getAnnotate", "getContents", + "getPrice", "getSize", "getChapter"); + + @Override public String getFormatName() { return "BibTeXML"; @@ -79,33 +95,169 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { List bibItems = new ArrayList<>(); - // Obtain a factory object for creating SAX parsers - SAXParserFactory parserFactory = SAXParserFactory.newInstance(); - // Configure the factory object to specify attributes of the parsers it - // creates - // parserFactory.setValidating(true); - parserFactory.setNamespaceAware(true); - // Now create a SAXParser object - try { - SAXParser parser = parserFactory.newSAXParser(); //May throw exceptions - BibTeXMLHandler handler = new BibTeXMLHandler(); - // Start the parser. It reads the file and calls methods of the handler. - parser.parse(new InputSource(reader), handler); - // When you're done, report the results stored by your handler object - bibItems.addAll(handler.getItems()); - - } catch (javax.xml.parsers.ParserConfigurationException e) { + JAXBContext context = JAXBContext.newInstance("net.sf.jabref.importer.fileformat.bibtexml"); + Unmarshaller unmarshaller = context.createUnmarshaller(); + File file = (File) unmarshaller.unmarshal(reader); + + List entries = file.getEntry(); + Map fields = new HashMap<>(); + + for (Entry entry : entries) { + BibEntry bibEntry = new BibEntry(); + if (entry.getArticle() != null) { + bibEntry.setType("article"); + parse(entry.getArticle(), fields); + } else if (entry.getBook() != null) { + bibEntry.setType("book"); + parse(entry.getBook(), fields); + } else if (entry.getBooklet() != null) { + bibEntry.setType("booklet"); + parse(entry.getBooklet(), fields); + } else if (entry.getConference() != null) { + bibEntry.setType("conference"); + parse(entry.getConference(), fields); + } else if (entry.getInbook() != null) { + bibEntry.setType("inbook"); + parseInbook(entry.getInbook(), fields); + } else if (entry.getIncollection() != null) { + bibEntry.setType("incollection"); + Incollection incollection = entry.getIncollection(); + if (incollection.getChapter() != null) { + fields.put(FieldName.CHAPTER, String.valueOf(incollection.getChapter())); + } + parse(incollection, fields); + } else if (entry.getInproceedings() != null) { + bibEntry.setType("inproceedings"); + parse(entry.getInproceedings(), fields); + } else if (entry.getManual() != null) { + bibEntry.setType("manual"); + parse(entry.getManual(), fields); + } else if (entry.getMastersthesis() != null) { + bibEntry.setType("mastersthesis"); + parse(entry.getMastersthesis(), fields); + } else if (entry.getMisc() != null) { + bibEntry.setType("misc"); + parse(entry.getMisc(), fields); + } else if (entry.getPhdthesis() != null) { + bibEntry.setType("phdthesis"); + parse(entry.getPhdthesis(), fields); + } else if (entry.getProceedings() != null) { + bibEntry.setType("proceedings"); + parse(entry.getProceedings(), fields); + } else if (entry.getTechreport() != null) { + bibEntry.setType("techreport"); + parse(entry.getTechreport(), fields); + } else if (entry.getUnpublished() != null) { + bibEntry.setType("unpublished"); + parse(entry.getUnpublished(), fields); + } + + if (entry.getId() != null) { + bibEntry.setCiteKey(entry.getId()); + } + bibEntry.setField(fields); + bibItems.add(bibEntry); + } + } catch (JAXBException e) { LOGGER.error("Error with XML parser configuration", e); return ParserResult.fromErrorMessage(e.getLocalizedMessage()); - } catch (org.xml.sax.SAXException e) { - LOGGER.error("Error during XML parsing", e); - return ParserResult.fromErrorMessage(e.getLocalizedMessage()); - } catch (IOException e) { - LOGGER.error("Error during file import", e); - return ParserResult.fromErrorMessage(e.getLocalizedMessage()); } return new ParserResult(bibItems); } + /** + * We use a generic method and not work on the real classes, because they all have the same behaviour. They call all get methods + * that are needed and use the return value. So this will prevent writing similar methods for every type. + *

+ * In this method, all get methods that entryType has will be used and their value will be put to fields, + * if it is not null. So for example if entryType has the method getAbstract, then + * "abstract" will be put as key to fields and the value of getAbstract will be put as value to fields. + * Some get methods shouldn't be mapped to fields, so getClass for example will be skipped. + * + * @param entryType This can be all possible BibTeX types. It contains all fields of the entry and their values. + * @param fields A map where the name and the value of all fields that the entry contains will be put. + */ + private void parse(T entryType, Map fields) { + Method[] declaredMethods = entryType.getClass().getDeclaredMethods(); + for (Method method : declaredMethods) { + try { + if (method.getName().equals("getYear")) { + putYear(fields, (XMLGregorianCalendar) method.invoke(entryType)); + continue; + } else if (method.getName().equals("getNumber")) { + putNumber(fields, (BigInteger) method.invoke(entryType)); + continue; + } else if (isMethodToIgnore(method.getName())) { + continue; + } else if (method.getName().startsWith("get")) { + putIfValueNotNull(fields, method.getName().replace("get", ""), (String) method.invoke(entryType)); + } + } catch (IllegalArgumentException | InvocationTargetException | IllegalAccessException e) { + LOGGER.error("Could not invoke method", e); + } + } + } + + /** + * Returns whether the value of the given method name should be mapped or whether the method can be ignored. + * + * @param methodName The name of the method as String + * @return true if the method can be ignored, else false + */ + private boolean isMethodToIgnore(String methodName) { + return IGNORED_METHODS.contains(methodName); + } + + /** + * Inbook needs a special Treatment, because inbook.getContent() returns a list of JAXBElements. + * The other types have just get methods, which return the values as Strings. + */ + private void parseInbook(Inbook inbook, Map fields) { + List> content = inbook.getContent(); + for (JAXBElement element : content) { + String localName = element.getName().getLocalPart(); + Object elementValue = element.getValue(); + if (elementValue instanceof String) { + String value = (String) elementValue; + putIfValueNotNull(fields, localName, value); + } else if (elementValue instanceof BigInteger) { + BigInteger value = (BigInteger) elementValue; + if (value != null) { + if (FieldName.NUMBER.equals(localName)) { + fields.put(FieldName.NUMBER, String.valueOf(value)); + } else if (FieldName.CHAPTER.equals(localName)) { + fields.put(FieldName.CHAPTER, String.valueOf(value)); + } + } + } else if (elementValue instanceof XMLGregorianCalendar) { + XMLGregorianCalendar value = (XMLGregorianCalendar) elementValue; + if (FieldName.YEAR.equals(localName)) { + putYear(fields, value); + } else { + LOGGER.info("Unexpected field was found"); + } + } else { + LOGGER.info("Unexpected field was found"); + } + } + } + + private void putYear(Map fields, XMLGregorianCalendar year) { + if (year != null) { + fields.put(FieldName.YEAR, String.valueOf(year)); + } + } + + private void putNumber(Map fields, BigInteger number) { + if (number != null) { + fields.put(FieldName.NUMBER, String.valueOf(number)); + } + } + + private void putIfValueNotNull(Map fields, String key, String value) { + if (value != null) { + fields.put(key, value); + } + } } diff --git a/src/main/java/net/sf/jabref/logic/importer/util/BibTeXMLHandler.java b/src/main/java/net/sf/jabref/logic/importer/util/BibTeXMLHandler.java deleted file mode 100644 index a5568895f16..00000000000 --- a/src/main/java/net/sf/jabref/logic/importer/util/BibTeXMLHandler.java +++ /dev/null @@ -1,107 +0,0 @@ -/* Copyright (C) 2003-2016 JabRef contributors. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ -package net.sf.jabref.logic.importer.util; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import net.sf.jabref.model.entry.BibEntry; -import net.sf.jabref.model.entry.IdGenerator; - -import org.xml.sax.Attributes; -import org.xml.sax.helpers.DefaultHandler; - -/** - * Reader for the BibTeXML format. See - * bibtexml.sf.net. - * - * @author Egon Willighagen - */ -public class BibTeXMLHandler extends DefaultHandler { - - private static final String BIBTEXML_URI = "http://bibtexml.sf.net/"; - - private List bibitems; - - private BibEntry b; // the entry being read - - // XML parsing stuff - private String currentChars; - - - public List getItems() { - if (bibitems == null) { - return Collections.emptyList(); - } - return bibitems; - } - - // SAX parsing methods - - @Override - public void startDocument() { - bibitems = new ArrayList<>(); - } - - @Override - public void characters(char[] ch, int start, int length) { - String s = new String(ch, start, length).trim(); - currentChars += s; - } - - @Override - public void startElement(String uri, String local, String raw, Attributes atts) { - if (BIBTEXML_URI.equals(uri)) { - if ("entry".equals(local)) { - b = new BibEntry(IdGenerator.next()); - // Determine and-set bibtex key - String bibtexKey = null; - for (int i = 0; i < atts.getLength(); i++) { - String attrURI = atts.getURI(i); - if ((BIBTEXML_URI.equals(attrURI) || "".equals(attrURI)) && "id".equals(atts.getLocalName(i))) { - bibtexKey = atts.getValue(i); - } - } - if (bibtexKey != null) { - b.setCiteKey(bibtexKey); - } - } else if ("article".equals(local) || "inbook".equals(local) || "book".equals(local) - || "booklet".equals(local) || "incollection".equals(local) || "inproceedings".equals(local) - || "proceedings".equals(local) || "manual".equals(local) || "mastersthesis".equals(local) - || "phdthesis".equals(local) || "techreport".equals(local) || "unpublished".equals(local) - || "misc".equals(local)) { - b.setType(local); - } - } - currentChars = ""; - } - - @Override - public void endElement(String uri, String local, String raw) { - if (BIBTEXML_URI.equals(uri)) { - if ("entry".equals(local)) { - bibitems.add(b); - } else { - if (!currentChars.trim().isEmpty()) { - b.setField(local, currentChars); - } - } - } - currentChars = ""; - } - -} diff --git a/src/main/resources/xjc/bibtexml/bibtexml.xsd b/src/main/resources/xjc/bibtexml/bibtexml.xsd new file mode 100644 index 00000000000..519ee240dcf --- /dev/null +++ b/src/main/resources/xjc/bibtexml/bibtexml.xsd @@ -0,0 +1,1001 @@ + + + + + + + + + + BibteXML bibliography schema + Author: Z.W. Hendrikse + Version: Adapted from $Revision: 1.1.1.1 $ + Copyright: GPL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + An abstract of the work. + + + + + + + The authors affiliation. + + + + + + + A Table of Contents. + + + + + + + Copyright information. + + + + + + + Digital Object Identifier number. + + + + + + + + + + + Key words used for searching or possibly for annotation. + + + + + + + The language the document is in. + + + + + + + The Library of Congress Call Number, also seen as lib-congress. + + + + + + + A location associated with the entry, + such as the city in which a conference took place. + + + + + + + The Mathematical Reviews number. + + + + + + + The price of the document. + + + + + + + The physical dimensions of a work. + + + + + + + The WWW Universal Resource Locator that points to the item being + referenced. This often is used for technical reports to point to + the ftp site where the postscript source of the report is located. + + + + + + + Category of this bibitem, added by Zeger W. Hendrikse. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The bibteXML equivalent of the @article tag. + An article from a journal or magazine. + Required fields: author, title, journal, year. + Optional fields: volume, number, pages, month, note. + + + + + + + + + + + + + + + + + + + + + + The bibteXML equivalent of the @book tag. + A book with an explicit publisher. + Required fields: author or editor, title, publisher, year. + Optional fields: volume or number, series, address, edition, + month, note. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The bibteXML equivalent of the @booklet tag. + A work that is printed and bound, but without a named + publisher or sponsoring institution. + Required fields: title. + Optional fields: author, howpublished, address, month, year, note. + + + + + + + + + + + + + + + + + + + + The bibteXML equivalent of the @conference tag. + The same as INPROCEEDINGS, included for Scribe compatibility. + + + + + + + + + + + + + The bibteXML equivalent of the @inbook tag. + A part of a book, which may be a chapter (or section or + publisher or sponsoring institution. + Required fields: author or editor, title, chapter and/or pages, + publisher, year. + Optional fields: fields: volume or number, series, type, address, + edition, month, note. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The bibteXML equivalent of the @incollection tag. + A part of a book having its own title. + Required fields: author, title, booktitle, publisher, year. + Optional fields: editor, volume or number, series, type, + chapter, pages, address, edition, month, note. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The bibteXML equivalent of the @inproceedings tag. + An article in a conference proceedings. + Required fields: author, title, booktitle, year. + Optional fields: editor, volume or number, series, pages, + address, month, organization, publisher, note. + + + + + + + + + + + + + The bibteXML equivalent of the @manual tag. + Technical documentation. + Required field: title. + Optional fields: author, organization, address, + edition, month, year, note. + + + + + + + + + + + + + + + + + + + + + The bibteXML equivalent of the @mastersthesis tag. + A Master's thesis. + Required fields: author, title, school, year. + Optional fields: type, address, month, note. + + + + + + + + + + + + + The bibteXML equivalent of the @misc tag. + Use this type when nothing else fits. + Required fields: none. + Optional fields: author, title, howpublished, month, year, note. + + + + + + + + + + + + + + + + + + + The bibteXML equivalent of the @phdthesis tag. + A PhD thesis. + Required fields: author, title, school, year. + Optional fields: type, address, month, note. + + + + + + + + + + + + + The bibteXML equivalent of the @proceedings tag. + The proceedings of a conference. + Required fields: title, year. + Optional fields: editor, volume or number, series, + address, month, organization, publisher, note. + + + + + + + + + + + + + + + + + + + + + + + + + + The bibteXML equivalent of the @techreport tag. + A report published by a school or other institution, + usually numbered within a series. + Required fields: author, title, institution, year. + Optional fields: type, number, address, month, note. + + + + + + + + + + + + + + + + + + + + + + The bibteXML equivalent of the @unpublished tag. + A document having an author and title, but not formally published. + Required fields: author, title, note. + Optional fields: month, year. + + + + + + + + + + + + + + + + + + + + + Usually the address of the publisher or other type of + institution. For major publishing houses, van Leunen recommends + omitting the information entirely. For small publishers, on the other + hand, you can help the reader by giving the complete address. + + + + + + + + + An annotation. It is not used by the standard bibliography + styles, but may be used by others that produce an annotated + bibliography. + + + + + + + + + The name(s) of the author(s), in the format described in the + LaTeX book. + + + + + + + + + Title of a book, part of which is being cited. See the + LaTeX book for how to type titles. For book entries, use the title + field instead. + + + + + + + + + A chapter (or section or whatever) number. + + + + + + + + + The database key of the entry being cross referenced. + + + + + + + + + The edition of a book-for example, ``Second''. This + should be an ordinal, and should have the first letter capitalized, as + shown here; the standard styles convert to lower case when necessary. + + + + + + + + + + + Name(s) of editor(s), typed as indicated in the LaTeX book. + If there is also an author field, then the editor field gives the + editor of the book or collection in which the reference appears. + + + + + + + + + How something strange has been published. The first + word should be capitalized. + + + + + + + + + The sponsoring institution of a technical report. + + + + + + + + + A journal name. Abbreviations are provided for many + journals; see the Local Guide. + + + + + + + + + Used for alphabetizing, cross referencing, and creating a label + when the ``author'' information (described in Section [ref: ] is + missing. This field should not be confused with the key that appears + in the \cite command and at the beginning of the database entry. + + + + + + + + + The month in which the work was published or, for an + unpublished work, in which it was written You should use the + standard three-letter abbreviation, as described in Appendix B.1.3 of + the LaTeX book. As XML Schema supports a special month format, it is + decided to allow e.g. 05 (for May) too. + + + + + + + + + Any additional information that can help the reader. The first + word should be capitalized. + + + + + + + + + The number of a journal, magazine, technical report, or of a + work in a series. An issue of a journal or magazine is usually + identified by its volume and number; the organization that issues a + technical report usually gives it a number; and sometimes books are + given numbers in a named series. + + + + + + + + + The organization that sponsors a conference or that publishes a manual. + + + + + + + + + One or more page numbers or range of numbers, such as 42-111 + or 7,41,73-97 or 43+ (the `+" in this last example indicates pages + following that don"t form a simple range). To make it easier to + maintain Scribe-compatible databases, the standard styles convert a + single dash (as in 7-33) to the double dash used in TeX to denote + number ranges (as in 7-33). + + + + + + + + + + + The publisher's name. + + + + + + + + + The name of the school where a thesis was written. + + + + + + + + + The name of a series or set of books. When citing an entire + book, the the title field gives its title and an optional series field + gives the name of a series or multi-volume set in which the book is + published. + + + + + + + + + The work's title, typed as explained in the LaTeX book. + + + + + + + + + The work's title, typed as explained in the LaTeX book. + + + + + + + + + The volume of a journal or multivolume book. + + + + + + + + + The year of publication or, for an unpublished work, the year + it was written. Generally it should consist of four numerals, such as + 1984. Although the standard styles can handle any year whose last four + nonpunctuation characters are numerals, such as `(about 1984)", it + is decided here to keep the year limited to four numerals, as such a + type is pre-defined in XML Schema. + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTest.java b/src/test/java/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTest.java index 164f34aba60..ec38d36827e 100644 --- a/src/test/java/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTest.java +++ b/src/test/java/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTest.java @@ -7,12 +7,10 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.stream.Collectors; import net.sf.jabref.Globals; -import net.sf.jabref.logic.importer.util.BibTeXMLHandler; import net.sf.jabref.logic.util.FileExtensions; import net.sf.jabref.preferences.JabRefPreferences; @@ -52,12 +50,6 @@ public void setUp() throws Exception { importer = new BibTeXMLImporter(); } - @Test - public void testGetItemsEmpty() { - BibTeXMLHandler handler = new BibTeXMLHandler(); - assertEquals(Collections.emptyList(), handler.getItems()); - } - @Test public void testGetFormatName() { assertEquals("BibTeXML", importer.getFormatName()); diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestArticle.xml b/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestArticle.xml index 9cbeb4328da..9fe49591a52 100644 --- a/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestArticle.xml +++ b/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestArticle.xml @@ -1,6 +1,6 @@ - + Max Mustermann Java tricks diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestConference.xml b/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestConference.xml new file mode 100644 index 00000000000..14bf2c26933 --- /dev/null +++ b/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestConference.xml @@ -0,0 +1,21 @@ + + + + + Max Mustermann + Maxima Musterfrau + Java Conference + Java Booktitle + Java Publisher + 2016 + 1 + February + 3-9 + 1 + 1 + Java Org + Stuttgart + java + + + diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestInbookLessFields.bib b/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestInbookLessFields.bib new file mode 100644 index 00000000000..4014194c1b0 --- /dev/null +++ b/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestInbookLessFields.bib @@ -0,0 +1,15 @@ +@InBook{Mustermann2016, + chapter = {10}, + title = {Java Conference}, + publisher = {Java Publisher}, + author = {Max Mustermann}, + editor = {Maxima Musterfrau}, + volume = {1}, + number = {1}, + series = {1}, + address = {Stuttgart}, + edition = {10}, + month = {February}, + note = {some note}, + keywords = {java}, +} diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestInbookLessFields.xml b/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestInbookLessFields.xml new file mode 100644 index 00000000000..2ebc8aa736e --- /dev/null +++ b/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestInbookLessFields.xml @@ -0,0 +1,22 @@ + + + + + Max Mustermann + Maxima Musterfrau + Java Conference + Java Booktitle + Java Publisher + 1 + February + 10 + 1 + 1 + Java Org + Stuttgart + java + 10 + some note + + + diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestIncollectionWithoutChapter.bib b/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestIncollectionWithoutChapter.bib new file mode 100644 index 00000000000..b716c95368d --- /dev/null +++ b/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestIncollectionWithoutChapter.bib @@ -0,0 +1,14 @@ +% Encoding: UTF-8 + +@InCollection{Mustermann2016, + author = {Max Mustermann}, + title = {Java InCollection}, + booktitle = {Java Testing}, + publisher = {Java Publisher}, + editor = {Maxima Musterfrau}, + volume = {1}, + number = {1}, + pages = {18-26}, + month = {February}, + keywords = {java} +} diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestIncollectionWithoutChapter.xml b/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestIncollectionWithoutChapter.xml new file mode 100644 index 00000000000..b2fbb3132a6 --- /dev/null +++ b/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestIncollectionWithoutChapter.xml @@ -0,0 +1,17 @@ + + + + + Max Mustermann + Maxima Musterfrau + Java InCollection + Java Testing + Java Publisher + 1 + February + 18-26 + 1 + java + + + diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestInvalidInbook.bib b/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestInvalidInbook.bib new file mode 100644 index 00000000000..84b1642b127 --- /dev/null +++ b/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestInvalidInbook.bib @@ -0,0 +1,3 @@ +@inbook{Mustermann2016, + +} \ No newline at end of file diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestInvalidInbook.xml b/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestInvalidInbook.xml new file mode 100644 index 00000000000..a9eed9f3c44 --- /dev/null +++ b/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestInvalidInbook.xml @@ -0,0 +1,8 @@ + + + + + should not be mapped, because not valid according to XSD + + + diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestTechReport.bib b/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestTechReport.bib index b23017cbc0a..1ab28ba275c 100644 --- a/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestTechReport.bib +++ b/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestTechReport.bib @@ -8,5 +8,4 @@ @TechReport{Mustermann2016 address = {Stuttgart}, month = {February}, keywords = {java}, - school = {JIOT} -} \ No newline at end of file +} diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestTechReport.xml b/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestTechReport.xml index d66e83d9860..24d8e57bad6 100644 --- a/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestTechReport.xml +++ b/src/test/resources/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTestTechReport.xml @@ -8,7 +8,6 @@ February 1 JIOT - JIOT Stuttgart Report java diff --git a/medline.gradle b/xjc.gradle similarity index 56% rename from medline.gradle rename to xjc.gradle index 94c5565c28a..8047f944d42 100644 --- a/medline.gradle +++ b/xjc.gradle @@ -8,7 +8,9 @@ dependencies { task xjc { inputs.dir "src/main/resources/xjc/medline/" - outputs.dir "src/main/gen/net/sf/jabref/logic/importer/fileformat/medline" + inputs.dir "src/main/resources/xjc/bibtexml/" + outputs.dir "src/main/gen/net/sf/jabref/importer/fileformat/medline" + outputs.dir "src/main/gen/net/sf/jabref/importer/fileformat/bibtexml" ant.taskdef(name: 'xjc', classname: 'com.sun.tools.xjc.XJCTask', classpath: configurations.xjc.asPath) @@ -16,6 +18,9 @@ task xjc { ant.xjc(destdir: 'src/main/gen/', package: 'net.sf.jabref.logic.importer.fileformat.medline') { schema(dir: 'src/main/resources/xjc/medline', includes: 'medline.xsd') } + ant.xjc(destdir: 'src/main/gen/', package: 'net.sf.jabref.importer.fileformat.bibtexml') { + schema(dir: 'src/main/resources/xjc/bibtexml', includes: 'bibtexml.xsd') + } } }