jabref icon indicating copy to clipboard operation
jabref copied to clipboard

Rewrite code of CitaviImporter to avoid JAXBContext

Open koppor opened this issue 2 years ago • 18 comments

The code of org.jabref.logic.importer.fileformat.CitaviXmlImporter is written OK, but relies on JAXB. It should be rewritten using StAX-Parser and thus getting rid of a JAXB dependency.

The code reads like we do not hit polymorphism in XMLElements (which is not supported by JAXB. See https://github.com/FasterXML/jackson-modules-base/issues/127).

See https://github.com/JabRef/jabref/blob/d21c11337a17af85047d763218c9df4dbc4db1be/src/main/java/org/jabref/logic/importer/fileformat/MedlineImporter.java#L114 for some code hints.

Similar to https://github.com/JabRef/jabref/pull/9673, the gradle build target generateCitaviSource can be removed and the xsd file be removed from the source repository.

Hints

Example file

  1. Open 7Zip gui
  2. Open src/test/resources/org/jabref/logic/importer/fileformat/CitaviXmlImporterTest4.ctv6bak in 7zip.
  3. Open citavi-single.xml using 7 zip

Initial coding

  1. Remove gradle task generateCitaviSource
  2. Remove src/main/resources/xjc/citavi/citavi.xsd
  3. Exectue gradle clean task.
  4. Observe that CitaviXmlImporter does not compile
  5. Try to understand how MedlineImporter handles XML importing
  6. Work on fixing it. -> You have a) an example file (see above) and b) similar code (MedlineImporter )

Negleted Implementation Option

Thus, it seems to be "just" to include the dependency to jackson module jakarta-xmlbind and to use Jackson's XMLMapper. Code examples are at https://stackify.com/java-xml-jackson/.

koppor avatar Jan 06 '23 14:01 koppor

We should really work on that to get rid off buildSrc

koppor avatar Sep 02 '23 21:09 koppor

Similar code refactoring: https://github.com/JabRef/jabref/pull/9880

koppor avatar Sep 02 '23 21:09 koppor

Hello, I'm a new contributor, and I will carefully read the contribution guidelines. Could you please assign this issue to me? @koppor

JoleneSun111 avatar Oct 11 '23 13:10 JoleneSun111

@JoleneSun111 If you want, you can also try https://github.com/FasterXML/StaxMate. However, that piece of library is not well documented. I would assume that basic Java Stax transformation is enough to solve the issue. - It is not straight-forward, but IMHO manageable nevertheless. The code is backed by tests, so there should be check if everything goes smoothely.

I remember we had the discussions that there have to build local data structures for the lookup of IDs.

koppor avatar Oct 13 '23 11:10 koppor

Hi @koppor, I would like to work on this if this issue is still open?

ShailikaS avatar Dec 28 '23 09:12 ShailikaS

Since there has not been any activity here since the abandoned pull-request from AvunArasi (#9928), I will assign you @ShailikaS.

ThiloteE avatar Dec 28 '23 12:12 ThiloteE

@ShailikaS you have been assigned. Are you still working on this? -- It could be a bit hard to implement...

koppor avatar Jan 22 '24 17:01 koppor

like to take on this issue, if possible

psyren99 avatar Jul 04 '24 22:07 psyren99

Welcome to the vibrant world of open-source development with JabRef!

Newcomers, we're excited to have you on board. Start by exploring our Contributing guidelines, and don't forget to check out our workspace setup guidelines to get started smoothly.

Having any questions or issues? Feel free to ask here on GitHub. Need help setting up your local workspace? Join the conversation on JabRef's Gitter chat. And don't hesitate to open a (draft) pull request early on to show the direction it is heading towards. This way, you will receive valuable feedback.

Happy coding! 🚀

github-actions[bot] avatar Jul 09 '24 22:07 github-actions[bot]