JATSParserPlugin
JATSParserPlugin copied to clipboard
Support for references
- [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.
@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.
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, 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.
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.
The idea is to parse references from the JATS XML, convert to the raw text but preserve the structure in the citation_settings
:
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.
I thought about that but didn't find a way to do this easily from a plugin.
I mean depending on user input. Say, if an option with a file from which to parse references is selected.
Or I can add an option to the plugin's settings and if it's chosen to remove that field...