JATSParserPlugin icon indicating copy to clipboard operation
JATSParserPlugin copied to clipboard

Support for references

Open Vitaliy-1 opened this issue 4 years ago • 9 comments

  • [x] - Parse references from JATS XML and save the raw text in the citations table.
  • [ ] - Reflect the reference structure in the citation_settings table.
  • [x] - Consider making a background for the support of different citation styles.

Vitaliy-1 avatar Jun 24 '20 09:06 Vitaliy-1

@NateWr, Currently there isn't an easy way to save citations from a hook as they are being rewritten in PKPPublicationService::edit: https://github.com/pkp/pkp-lib/blob/d5c9d956ba6f611253f06853c01d3309b7ca57b6/classes/services/PKPPublicationService.inc.php#L530 Ideally, this code should be executed before the hook or allow modification of params by reference.

Vitaliy-1 avatar Aug 14 '20 07:08 Vitaliy-1

Have you considered just removing the existing saved citations and saving your own? It's not the most performant approach, but typically write actions aren't where we see performance bottlenecks, so it may be alright.

I'm a little nervous about letting plugins modify the $params because it can lead to cross-plugin errors that are hard to identify and debug. For example, if someone wrote a separate plugin that hooked in and took some actions based on references in $params, the two plugins would conflict depending on their load order. How would this impact the Crossref Reference Linking plugin, for example?

NateWr avatar Aug 17 '20 10:08 NateWr

@NateWr, yes, this was the initial plan. I've saved citations in a citationsRaw and they have been successfully parsed. The problem is that I can't add anything to the citation_settings. The hook appears before the importCitations which deletes all of the citations associated with the current publication id.

Vitaliy-1 avatar Aug 17 '20 12:08 Vitaliy-1

Ah, I understand now. For the hook system to work like this you probably would want a citation service class and something like a Citation::add hook. It may be that we just need to add a hook to CitationDAO::insertObject() in the interim.

Can you describe what you're trying to do in more detail? I'm wondering if it's better to handle your citation needs in a different way.

NateWr avatar Aug 17 '20 12:08 NateWr

The idea is to parse references from the JATS XML, convert to the raw text but preserve the structure in the citation_settings: example

Vitaliy-1 avatar Aug 17 '20 15:08 Vitaliy-1

What about removing the existing citationsRaw field from the form altogether? In that case, you'd do all of the citation stuff yourself from the XML.

NateWr avatar Aug 17 '20 15:08 NateWr

I thought about that but didn't find a way to do this easily from a plugin.

Vitaliy-1 avatar Aug 17 '20 16:08 Vitaliy-1

I mean depending on user input. Say, if an option with a file from which to parse references is selected.

Vitaliy-1 avatar Aug 17 '20 16:08 Vitaliy-1

Or I can add an option to the plugin's settings and if it's chosen to remove that field...

Vitaliy-1 avatar Aug 17 '20 16:08 Vitaliy-1