-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite bibtexml importer with JAXB parser #1666
Conversation
bibEntry.setType("unpublished"); | ||
parseUnpublished(entry.getUnpublished(), fields); | ||
} | ||
if (entry.getId() != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if condition shouldn't be necessary as the xsd schema file specifies the attribute as use="required"
if (method.getName().equals("getNumber")) { | ||
putNumber(fields, (BigInteger) method.invoke(t)); | ||
continue; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use else if
6991e26
to
025ee20
Compare
* "abstract" will be put as key to fields and the value of <Code>getAbstract</Code> will be put as value to fields. | ||
* Some <Code>get</Code> methods shouldn't be mapped to fields, so <Code>getClass</Code> for example will be skipped. | ||
* | ||
* @param t |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either write a parameter description or leave the tag out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also rename, maybe entryType
is fitting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed it to entryType and added a description.
f0cc410
to
fe63c1a
Compare
} | ||
return new ParserResult(bibItems); | ||
} | ||
|
||
/** | ||
* In this method, all <Code>get</Code> methods that t has will be used and their value will be put to fields, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t
-> entryType
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
Are there any other remarks? |
} catch (javax.xml.parsers.ParserConfigurationException e) { | ||
JAXBContext context = JAXBContext.newInstance("net.sf.jabref.importer.fileformat.bibtexml"); | ||
XMLInputFactory xmlInputFactory = XMLInputFactory.newFactory(); | ||
XMLStreamReader xmlReader = xmlInputFactory.createXMLStreamReader(reader); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't directly the reader used as input for the unmarshaller?
The JavaDocs of the unmarshaller say so: https://jaxb.java.net/nonav/2.2.4/docs/api/javax/xml/bind/Unmarshaller.html
Reading that, the code would be much shorter and especially lines 106 to 109 would be obsolete
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I've used directly the reader as input.
# Conflicts: # src/main/java/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporter.java # src/test/java/net/sf/jabref/logic/importer/fileformat/BibTeXMLImporterTest.java
Travis is failing because of UI tests... |
Please not that the UI tests are done but ignored. Please read the travis output and check for red lines Checkstyle failed. Your IDE settings seem to be non-formant. Please double check: https://github.com/JabRef/jabref/wiki/Guidelines-for-setting-up-a-local-workspace#intellij
|
* master: Fix imports Rename NewFileDialog -> FileDialog Also cancel duplicate finder workflow on close button Removed/moved preferences which are constants implements JabRef#1767: Add Help Button to access new help page Fixed BibTeXMLImporter Set more default file filters in dialogs JabRef#1763 Resolve crossrefs and strings in main table (JabRef#1644) Rewrite bibtexml importer with JAXB parser (JabRef#1666) Moved a few more initialization to GUIGlobals.init() (JabRef#1756) Added program to generate a table of all characters and fixed some characters (JabRef#1766) Improve focus of the maintable after a sidepane gets closed (JabRef#1741) Table row height adjusts on Windows as the font scales with the menu (JabRef#1623) Added more characters to converters (JabRef#1761)
* rewrite bibtexml importer with jaxb parser * address comments * remove unused import * include feedback * fix import order, log and add testfile
Regarding: #898
I'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.
Note: Exporting in bibtexml format and then trying to import in bibtexml format is not working because of #1665.