Skip to content
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 code of ModsExporter #9682

Closed
koppor opened this issue Mar 18, 2023 · 5 comments · Fixed by #9860
Closed

Rewrite code of ModsExporter #9682

koppor opened this issue Mar 18, 2023 · 5 comments · Fixed by #9860
Assignees
Labels
type: code-quality Issues related to code or architecture decisions

Comments

@koppor
Copy link
Member

koppor commented Mar 18, 2023

The class org.jabref.logic.exporter.ModsExporter uses JAXB, but can be rewritten using a StAX-Writer and thus getting rid of a JAXB dependency. (Please also set the correct namespaces!).

Example:

Old code:

    JAXBElement<ModsCollectionDefinition> jaxbElement = new JAXBElement<>(
                    new QName(MODS_NAMESPACE_URI, "modsCollection"), ModsCollectionDefinition.class, modsCollection);

New code:

            writer.writeStartDocument("utf-8", "1.0");
            writer.writeStartElement(MODS_NAMESPACE_URI, "modsCollection");
            ... export of ModsCoillectionDefinition ...
            writer.writeEndElement();
            writer.writeEndDocument();

Similar to #9673, the gradle build target generateModsSource can be removed and the xsd file be removed from the source repository.

@koppor koppor added the type: code-quality Issues related to code or architecture decisions label Mar 18, 2023
@yenniejunvu
Copy link
Contributor

Hi! I am a uni student and would like to attempt this.

@ThiloteE
Copy link
Member

ThiloteE commented Apr 2, 2023

This is actually a much needed change, as we are currently struggling with having too many dependencies and scratching the limit. Thank you for choosing this issue!

@yenniejunvu
Copy link
Contributor

I am glad to be of assistance. I am not very familiar with either JAXB or StAX, so I am reading some documentation to familiarize myself. Other than that, are there other pointers on where to begin for this task?

@Siedlerchr
Copy link
Member

Just look at the other implementations that have been already converted

@koppor
Copy link
Member Author

koppor commented Apr 3, 2023

The deep link to the changed code is at #9673.

Together with the PR, the howto linked at https://mkyong.com/java/how-to-write-xml-file-in-java-stax-writer/ should be enough to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: code-quality Issues related to code or architecture decisions
Projects
Archived in project
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants