{"action":"created","comment":{"url":"https://api.github.com/repos/JabRef/jabref/pulls/comments/74562633","id":74562633,"diff_hunk":"@@ -78,33 +98,177 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {\n \n         List<BibEntry> bibItems = new ArrayList<>();\n \n-        // Obtain a factory object for creating SAX parsers\n-        SAXParserFactory parserFactory = SAXParserFactory.newInstance();\n-        // Configure the factory object to specify attributes of the parsers it\n-        // creates\n-        // parserFactory.setValidating(true);\n-        parserFactory.setNamespaceAware(true);\n-        // Now create a SAXParser object\n-\n         try {\n-            SAXParser parser = parserFactory.newSAXParser(); //May throw exceptions\n-            BibTeXMLHandler handler = new BibTeXMLHandler();\n-            // Start the parser. It reads the file and calls methods of the handler.\n-            parser.parse(new InputSource(reader), handler);\n-            // When you're done, report the results stored by your handler object\n-            bibItems.addAll(handler.getItems());\n-\n-        } catch (javax.xml.parsers.ParserConfigurationException e) {\n+            JAXBContext context = JAXBContext.newInstance(\"net.sf.jabref.importer.fileformat.bibtexml\");\n+            XMLInputFactory xmlInputFactory = XMLInputFactory.newFactory();\n+            XMLStreamReader xmlReader = xmlInputFactory.createXMLStreamReader(reader);\n+\n+            //go to the root element\n+            while (!xmlReader.isStartElement()) {\n+                xmlReader.next();\n+            }\n+\n+            Unmarshaller unmarshaller = context.createUnmarshaller();\n+            File file = (File) unmarshaller.unmarshal(xmlReader);\n+\n+            List<Entry> entries = file.getEntry();\n+            Map<String, String> fields = new HashMap<>();\n+\n+            for (Entry entry : entries) {\n+                BibEntry bibEntry = new BibEntry(DEFAULT_BIBTEXENTRY_ID);\n+                if (entry.getArticle() != null) {\n+                    bibEntry.setType(\"article\");\n+                    parse(entry.getArticle(), fields);\n+                }\n+                if (entry.getBook() != null) {\n+                    bibEntry.setType(\"book\");\n+                    parse(entry.getBook(), fields);\n+                }\n+                if (entry.getBooklet() != null) {\n+                    bibEntry.setType(\"booklet\");\n+                    parse(entry.getBooklet(), fields);\n+                }\n+                if (entry.getConference() != null) {\n+                    bibEntry.setType(\"conference\");\n+                    parse(entry.getConference(), fields);\n+                }\n+                if (entry.getInbook() != null) {\n+                    bibEntry.setType(\"inbook\");\n+                    parseInbook(entry.getInbook(), fields);\n+                }\n+                if (entry.getIncollection() != null) {\n+                    bibEntry.setType(\"incollection\");\n+                    Incollection incollection = entry.getIncollection();\n+                    if (incollection.getChapter() != null) {\n+                        fields.put(FieldName.CHAPTER, String.valueOf(incollection.getChapter()));\n+                    }\n+                    parse(incollection, fields);\n+                }\n+                if (entry.getInproceedings() != null) {\n+                    bibEntry.setType(\"inproceedings\");\n+                    parse(entry.getInproceedings(), fields);\n+                }\n+                if (entry.getManual() != null) {\n+                    bibEntry.setType(\"manual\");\n+                    parse(entry.getManual(), fields);\n+                }\n+                if (entry.getMastersthesis() != null) {\n+                    bibEntry.setType(\"mastersthesis\");\n+                    parse(entry.getMastersthesis(), fields);\n+                }\n+                if (entry.getMisc() != null) {\n+                    bibEntry.setType(\"misc\");\n+                    parse(entry.getMisc(), fields);\n+                }\n+                if (entry.getPhdthesis() != null) {\n+                    bibEntry.setType(\"phdthesis\");\n+                    parse(entry.getPhdthesis(), fields);\n+                }\n+                if (entry.getProceedings() != null) {\n+                    bibEntry.setType(\"proceedings\");\n+                    parse(entry.getProceedings(), fields);\n+                }\n+                if (entry.getTechreport() != null) {\n+                    bibEntry.setType(\"techreport\");\n+                    parse(entry.getTechreport(), fields);\n+                }\n+                if (entry.getUnpublished() != null) {\n+                    bibEntry.setType(\"unpublished\");\n+                    parse(entry.getUnpublished(), fields);\n+                }\n+                if (entry.getId() != null) {\n+                    bibEntry.setCiteKey(entry.getId());\n+                }\n+                bibEntry.setField(fields);\n+                bibItems.add(bibEntry);\n+            }\n+        } catch (JAXBException | XMLStreamException e) {\n             LOGGER.error(\"Error with XML parser configuration\", e);\n             return ParserResult.fromErrorMessage(e.getLocalizedMessage());\n-        } catch (org.xml.sax.SAXException e) {\n-            LOGGER.error(\"Error during XML parsing\", e);\n-            return ParserResult.fromErrorMessage(e.getLocalizedMessage());\n-        } catch (IOException e) {\n-            LOGGER.error(\"Error during file import\", e);\n-            return ParserResult.fromErrorMessage(e.getLocalizedMessage());\n         }\n         return new ParserResult(bibItems);\n     }\n \n+    /**\n+     * In this method, all <Code>get</Code> methods that t has will be used and their value will be put to fields,\n+     * if it is not null. So for example if entryType has the method <Code>getAbstract</Code>, then\n+     * \"abstract\" will be put as key to fields and the value of <Code>getAbstract</Code> will be put as value to fields.\n+     * Some <Code>get</Code> methods shouldn't be mapped to fields, so <Code>getClass</Code> for example will be skipped.\n+     *\n+     * @param entryType This can be all possible BibTeX types. It contains all fields of the entry and their values.\n+     * @param fields A map where the name and the value of all fields, that the entry contains, will be put.","path":"src/main/java/net/sf/jabref/importer/fileformat/BibTeXMLImporter.java","position":176,"original_position":176,"commit_id":"fe63c1a6f2acfb8f2d2ab4538b37412fe853e2c7","original_commit_id":"fe63c1a6f2acfb8f2d2ab4538b37412fe853e2c7","user":{"login":"koppor","id":1366654,"avatar_url":"https://avatars.githubusercontent.com/u/1366654?v=3","gravatar_id":"","url":"https://api.github.com/users/koppor","html_url":"https://github.com/koppor","followers_url":"https://api.github.com/users/koppor/followers","following_url":"https://api.github.com/users/koppor/following{/other_user}","gists_url":"https://api.github.com/users/koppor/gists{/gist_id}","starred_url":"https://api.github.com/users/koppor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koppor/subscriptions","organizations_url":"https://api.github.com/users/koppor/orgs","repos_url":"https://api.github.com/users/koppor/repos","events_url":"https://api.github.com/users/koppor/events{/privacy}","received_events_url":"https://api.github.com/users/koppor/received_events","type":"User","site_admin":false},"body":"Remove commas","created_at":"2016-08-12T09:18:33Z","updated_at":"2016-08-12T09:18:33Z","html_url":"https://github.com/JabRef/jabref/pull/1666#discussion_r74562633","pull_request_url":"https://api.github.com/repos/JabRef/jabref/pulls/1666","_links":{"self":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/comments/74562633"},"html":{"href":"https://github.com/JabRef/jabref/pull/1666#discussion_r74562633"},"pull_request":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/1666"}}},"pull_request":{"url":"https://api.github.com/repos/JabRef/jabref/pulls/1666","id":79742001,"html_url":"https://github.com/JabRef/jabref/pull/1666","diff_url":"https://github.com/JabRef/jabref/pull/1666.diff","patch_url":"https://github.com/JabRef/jabref/pull/1666.patch","issue_url":"https://api.github.com/repos/JabRef/jabref/issues/1666","number":1666,"state":"open","locked":false,"title":"Rewrite bibtexml importer with JAXB parser","user":{"login":"tschechlovdev","id":15339876,"avatar_url":"https://avatars.githubusercontent.com/u/15339876?v=3","gravatar_id":"","url":"https://api.github.com/users/tschechlovdev","html_url":"https://github.com/tschechlovdev","followers_url":"https://api.github.com/users/tschechlovdev/followers","following_url":"https://api.github.com/users/tschechlovdev/following{/other_user}","gists_url":"https://api.github.com/users/tschechlovdev/gists{/gist_id}","starred_url":"https://api.github.com/users/tschechlovdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tschechlovdev/subscriptions","organizations_url":"https://api.github.com/users/tschechlovdev/orgs","repos_url":"https://api.github.com/users/tschechlovdev/repos","events_url":"https://api.github.com/users/tschechlovdev/events{/privacy}","received_events_url":"https://api.github.com/users/tschechlovdev/received_events","type":"User","site_admin":false},"body":"Regarding: #898 \r\nI've rewritten the bibtexml importer: It was written with a SAX parser and I've used a JAXB parser. I will be addings some more tests for the changes I've made.\r\n\r\nNote: Exporting in bibtexml format and then trying to import in bibtexml format is not working because of #1665.\r\n\r\n- [x] Tests created for changes\r\n- [x] Manually tested changed features in running JabRef\r\n","created_at":"2016-08-02T14:10:58Z","updated_at":"2016-08-12T09:18:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"93dcc13d9717a7ab4b9e796ae227a436f2221ddc","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/JabRef/jabref/pulls/1666/commits","review_comments_url":"https://api.github.com/repos/JabRef/jabref/pulls/1666/comments","review_comment_url":"https://api.github.com/repos/JabRef/jabref/pulls/comments{/number}","comments_url":"https://api.github.com/repos/JabRef/jabref/issues/1666/comments","statuses_url":"https://api.github.com/repos/JabRef/jabref/statuses/fe63c1a6f2acfb8f2d2ab4538b37412fe853e2c7","head":{"label":"tschechlovdev:bibtexml-importer","ref":"bibtexml-importer","sha":"fe63c1a6f2acfb8f2d2ab4538b37412fe853e2c7","user":{"login":"tschechlovdev","id":15339876,"avatar_url":"https://avatars.githubusercontent.com/u/15339876?v=3","gravatar_id":"","url":"https://api.github.com/users/tschechlovdev","html_url":"https://github.com/tschechlovdev","followers_url":"https://api.github.com/users/tschechlovdev/followers","following_url":"https://api.github.com/users/tschechlovdev/following{/other_user}","gists_url":"https://api.github.com/users/tschechlovdev/gists{/gist_id}","starred_url":"https://api.github.com/users/tschechlovdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tschechlovdev/subscriptions","organizations_url":"https://api.github.com/users/tschechlovdev/orgs","repos_url":"https://api.github.com/users/tschechlovdev/repos","events_url":"https://api.github.com/users/tschechlovdev/events{/privacy}","received_events_url":"https://api.github.com/users/tschechlovdev/received_events","type":"User","site_admin":false},"repo":{"id":46298017,"name":"jabref","full_name":"tschechlovdev/jabref","owner":{"login":"tschechlovdev","id":15339876,"avatar_url":"https://avatars.githubusercontent.com/u/15339876?v=3","gravatar_id":"","url":"https://api.github.com/users/tschechlovdev","html_url":"https://github.com/tschechlovdev","followers_url":"https://api.github.com/users/tschechlovdev/followers","following_url":"https://api.github.com/users/tschechlovdev/following{/other_user}","gists_url":"https://api.github.com/users/tschechlovdev/gists{/gist_id}","starred_url":"https://api.github.com/users/tschechlovdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tschechlovdev/subscriptions","organizations_url":"https://api.github.com/users/tschechlovdev/orgs","repos_url":"https://api.github.com/users/tschechlovdev/repos","events_url":"https://api.github.com/users/tschechlovdev/events{/privacy}","received_events_url":"https://api.github.com/users/tschechlovdev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tschechlovdev/jabref","description":"Graphical Java application for managing bibtex (.bib) databases","fork":true,"url":"https://api.github.com/repos/tschechlovdev/jabref","forks_url":"https://api.github.com/repos/tschechlovdev/jabref/forks","keys_url":"https://api.github.com/repos/tschechlovdev/jabref/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tschechlovdev/jabref/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tschechlovdev/jabref/teams","hooks_url":"https://api.github.com/repos/tschechlovdev/jabref/hooks","issue_events_url":"https://api.github.com/repos/tschechlovdev/jabref/issues/events{/number}","events_url":"https://api.github.com/repos/tschechlovdev/jabref/events","assignees_url":"https://api.github.com/repos/tschechlovdev/jabref/assignees{/user}","branches_url":"https://api.github.com/repos/tschechlovdev/jabref/branches{/branch}","tags_url":"https://api.github.com/repos/tschechlovdev/jabref/tags","blobs_url":"https://api.github.com/repos/tschechlovdev/jabref/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tschechlovdev/jabref/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tschechlovdev/jabref/git/refs{/sha}","trees_url":"https://api.github.com/repos/tschechlovdev/jabref/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tschechlovdev/jabref/statuses/{sha}","languages_url":"https://api.github.com/repos/tschechlovdev/jabref/languages","stargazers_url":"https://api.github.com/repos/tschechlovdev/jabref/stargazers","contributors_url":"https://api.github.com/repos/tschechlovdev/jabref/contributors","subscribers_url":"https://api.github.com/repos/tschechlovdev/jabref/subscribers","subscription_url":"https://api.github.com/repos/tschechlovdev/jabref/subscription","commits_url":"https://api.github.com/repos/tschechlovdev/jabref/commits{/sha}","git_commits_url":"https://api.github.com/repos/tschechlovdev/jabref/git/commits{/sha}","comments_url":"https://api.github.com/repos/tschechlovdev/jabref/comments{/number}","issue_comment_url":"https://api.github.com/repos/tschechlovdev/jabref/issues/comments{/number}","contents_url":"https://api.github.com/repos/tschechlovdev/jabref/contents/{+path}","compare_url":"https://api.github.com/repos/tschechlovdev/jabref/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tschechlovdev/jabref/merges","archive_url":"https://api.github.com/repos/tschechlovdev/jabref/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tschechlovdev/jabref/downloads","issues_url":"https://api.github.com/repos/tschechlovdev/jabref/issues{/number}","pulls_url":"https://api.github.com/repos/tschechlovdev/jabref/pulls{/number}","milestones_url":"https://api.github.com/repos/tschechlovdev/jabref/milestones{/number}","notifications_url":"https://api.github.com/repos/tschechlovdev/jabref/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tschechlovdev/jabref/labels{/name}","releases_url":"https://api.github.com/repos/tschechlovdev/jabref/releases{/id}","deployments_url":"https://api.github.com/repos/tschechlovdev/jabref/deployments","created_at":"2015-11-16T19:45:21Z","updated_at":"2016-03-10T11:41:18Z","pushed_at":"2016-08-11T11:11:05Z","git_url":"git://github.com/tschechlovdev/jabref.git","ssh_url":"git@github.com:tschechlovdev/jabref.git","clone_url":"https://github.com/tschechlovdev/jabref.git","svn_url":"https://github.com/tschechlovdev/jabref","homepage":"http://jabref.sourceforge.net/","size":86416,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"JabRef:master","ref":"master","sha":"3fdaa39c6995b76fa3e463d8aeab5dad6d6d1dbd","user":{"login":"JabRef","id":3914421,"avatar_url":"https://avatars.githubusercontent.com/u/3914421?v=3","gravatar_id":"","url":"https://api.github.com/users/JabRef","html_url":"https://github.com/JabRef","followers_url":"https://api.github.com/users/JabRef/followers","following_url":"https://api.github.com/users/JabRef/following{/other_user}","gists_url":"https://api.github.com/users/JabRef/gists{/gist_id}","starred_url":"https://api.github.com/users/JabRef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JabRef/subscriptions","organizations_url":"https://api.github.com/users/JabRef/orgs","repos_url":"https://api.github.com/users/JabRef/repos","events_url":"https://api.github.com/users/JabRef/events{/privacy}","received_events_url":"https://api.github.com/users/JabRef/received_events","type":"Organization","site_admin":false},"repo":{"id":17634071,"name":"jabref","full_name":"JabRef/jabref","owner":{"login":"JabRef","id":3914421,"avatar_url":"https://avatars.githubusercontent.com/u/3914421?v=3","gravatar_id":"","url":"https://api.github.com/users/JabRef","html_url":"https://github.com/JabRef","followers_url":"https://api.github.com/users/JabRef/followers","following_url":"https://api.github.com/users/JabRef/following{/other_user}","gists_url":"https://api.github.com/users/JabRef/gists{/gist_id}","starred_url":"https://api.github.com/users/JabRef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JabRef/subscriptions","organizations_url":"https://api.github.com/users/JabRef/orgs","repos_url":"https://api.github.com/users/JabRef/repos","events_url":"https://api.github.com/users/JabRef/events{/privacy}","received_events_url":"https://api.github.com/users/JabRef/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/JabRef/jabref","description":"Graphical Java application for managing BibTeX and Biblatex (.bib) databases","fork":false,"url":"https://api.github.com/repos/JabRef/jabref","forks_url":"https://api.github.com/repos/JabRef/jabref/forks","keys_url":"https://api.github.com/repos/JabRef/jabref/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JabRef/jabref/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JabRef/jabref/teams","hooks_url":"https://api.github.com/repos/JabRef/jabref/hooks","issue_events_url":"https://api.github.com/repos/JabRef/jabref/issues/events{/number}","events_url":"https://api.github.com/repos/JabRef/jabref/events","assignees_url":"https://api.github.com/repos/JabRef/jabref/assignees{/user}","branches_url":"https://api.github.com/repos/JabRef/jabref/branches{/branch}","tags_url":"https://api.github.com/repos/JabRef/jabref/tags","blobs_url":"https://api.github.com/repos/JabRef/jabref/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JabRef/jabref/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JabRef/jabref/git/refs{/sha}","trees_url":"https://api.github.com/repos/JabRef/jabref/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JabRef/jabref/statuses/{sha}","languages_url":"https://api.github.com/repos/JabRef/jabref/languages","stargazers_url":"https://api.github.com/repos/JabRef/jabref/stargazers","contributors_url":"https://api.github.com/repos/JabRef/jabref/contributors","subscribers_url":"https://api.github.com/repos/JabRef/jabref/subscribers","subscription_url":"https://api.github.com/repos/JabRef/jabref/subscription","commits_url":"https://api.github.com/repos/JabRef/jabref/commits{/sha}","git_commits_url":"https://api.github.com/repos/JabRef/jabref/git/commits{/sha}","comments_url":"https://api.github.com/repos/JabRef/jabref/comments{/number}","issue_comment_url":"https://api.github.com/repos/JabRef/jabref/issues/comments{/number}","contents_url":"https://api.github.com/repos/JabRef/jabref/contents/{+path}","compare_url":"https://api.github.com/repos/JabRef/jabref/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JabRef/jabref/merges","archive_url":"https://api.github.com/repos/JabRef/jabref/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JabRef/jabref/downloads","issues_url":"https://api.github.com/repos/JabRef/jabref/issues{/number}","pulls_url":"https://api.github.com/repos/JabRef/jabref/pulls{/number}","milestones_url":"https://api.github.com/repos/JabRef/jabref/milestones{/number}","notifications_url":"https://api.github.com/repos/JabRef/jabref/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JabRef/jabref/labels{/name}","releases_url":"https://api.github.com/repos/JabRef/jabref/releases{/id}","deployments_url":"https://api.github.com/repos/JabRef/jabref/deployments","created_at":"2014-03-11T14:48:42Z","updated_at":"2016-08-11T19:16:49Z","pushed_at":"2016-08-12T09:08:45Z","git_url":"git://github.com/JabRef/jabref.git","ssh_url":"git@github.com:JabRef/jabref.git","clone_url":"https://github.com/JabRef/jabref.git","svn_url":"https://github.com/JabRef/jabref","homepage":"http://www.jabref.org","size":93694,"stargazers_count":326,"watchers_count":326,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":247,"mirror_url":null,"open_issues_count":180,"forks":247,"open_issues":180,"watchers":326,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/1666"},"html":{"href":"https://github.com/JabRef/jabref/pull/1666"},"issue":{"href":"https://api.github.com/repos/JabRef/jabref/issues/1666"},"comments":{"href":"https://api.github.com/repos/JabRef/jabref/issues/1666/comments"},"review_comments":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/1666/comments"},"review_comment":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/1666/commits"},"statuses":{"href":"https://api.github.com/repos/JabRef/jabref/statuses/fe63c1a6f2acfb8f2d2ab4538b37412fe853e2c7"}}}}
{"actor":{"display_login":"koppor"}}