Hi, I am using OJS 3.2.1 and I try import my issues from XML which I have generated.
In my XML’s files is fields:
< citations >
< citation ></ citation >
…
</ citations >
I field them, then Imported to OJS. Everything was imported successfully without any errors, but when I check my article I doesn’t see References section.
Also I don’t see references In administration panel. Why citations doesn’t upload to my site?
And yes, I have enabled checkbox in the settings workflow.
I was going to open a thread on this but @dmasta got there first. I get the same issue described above, i.e. citations present in XML but not visible in the UI once loaded. I double checked that references were enabled before loading the XML.
I checked the database and citations seem to be present in the citations table, with all citations for a given article/publication stored in a single row in the raw_citation column. Is that the expected way they should be stored at db level?
Thanks,
Eoghan
hi @asmecher,
Can you confirm what the expected behavior should be for this?
Thanks,
Eoghan
Hi @eocarragain,
Can you test changes, replace this line: pkp-lib/NativeXmlPKPPublicationFilter.inc.php at d55739b90a9ac9460d0e1916946223c376ce4e4c · pkp/pkp-lib · GitHub
to
$citationsString = '';
foreach ($n->childNodes as $citNode) {
$citationsString .= $citNode->textContent() . "\n";
}
Let me know if not or if it doesn’t help.
Hi, I don’t have that file.
Hi
Thanks @Vitaliy that definitely seems to help. Note, I initially got a fatal php error and had to edit your code slightly (removing parens after “->textContent”):
$citationsString = '';
foreach ($n->childNodes as $citNode) {
$citationsString .= $citNode->textContent . "\n";
}
When I look in the database, I can see that each citation is correctly parsed into its own row. However, in the UI, when I view the submission Workflow & look at References under the Production Tab, the box is still empty. I assume I should be seeing each citation there?
Database:
UI for same publication (submission 3037):
@dmasta the file is under the /lib folder: “lib/pkp/plugins/importexport/native/filter/NativeXmlPKPPublicationFilter.inc.php”
Thanks very much!
Eoghan
Hi again @Vitaliy @asmecher @dmasta
Another bit of information. I did some more comparison in the database between publications loaded via the native xml import/export against publications where i manually entered the citations into the References box in the UI (manually entered references behave as expected).
With @Vitaliy’s fix above, they both look the same in the citations table (i.e. one row per reference).
However, for the manually entered publication, there is data in the “publication_settings” table with a “setting_name” of “citationsRaw”
Whereas for publications loaded via the Native import/export plugin, there is no relevant “citationsRaw” info in the “publication_settings” table:
By the way, I have nothing at all in my citation_settings table (it is empty)
Thanks,
Eoghan
You are absolutely right. textContent
is a property, not a method/function, and should be used without those.
As you already noticed, the data in the References field comes from citationsRaw
. When a user enters information there, it’s saved as a citationsRaw
property of a publication in the publication_settings
table and is parsed into single citations with CitationDAO::importCitations
.
I guess, instead of using direct import, it can make more sense to update citationsRaw
of a publication, e.g., instead of:
$citationDao = DAORegistry::getDAO('CitationDAO'); /** @var $citationDao CitationDAO */
$citationDao->importCitations($publicationId, $citationsString);
import with
$publication->setData('citationsRaw', $citationsString);
Yes, currently this table isn’t used.
Hmm, both operations should be performed here. I think I got it. Thanks!
You can track the issue here: Native citations import doesn't break citations string into single citations · Issue #6331 · pkp/pkp-lib · GitHub
Thanks @Vitaliy
I commented out the two $citationDao lines above and replaced them with the line to set the citationsRaw.
Confirming that when I load XML with this change, I can see them in the References box in the UI.
In the DB the information is in the publication_settings table, but individual references do not appear at all in the citations table.
I haven’t tested, but I assume leaving the two lines beginning with $citationDao in place and adding your new line would mean data would be in both tables, i.e.:
$citationDao = DAORegistry::getDAO('CitationDAO'); /** @var $citationDao CitationDAO */
$citationDao->importCitations($publicationId, $citationsString);
$publication->setData('citationsRaw', $citationsString);
I’ll test that now. I assume the data should be in both places or is one being deprecated? Thanks
Eoghan
Yes, my test shows the same.
Thanks
Just tried that again with all three lines of code as above.
Confirming that the data is in both tables and references display in the UI. This now appears to match the behaviour when manually entering citations through the UI.
@dmasta, for reference, my modified parseCitation method now looks like this:
/**
* Parse a publication citation and add it to the publication.
* @param $n DOMElement
* @param $publication PKPPublication
*/
function parseCitations($n, $publication) {
$publicationId = $publication->getId();
//$citationsString = $n->textContent;
$citationsString = '';
foreach ($n->childNodes as $citNode) {
$citationsString .= $citNode->textContent . "\n";
}
$citationDao = DAORegistry::getDAO('CitationDAO'); /** @var $citationDao CitationDAO */
$citationDao->importCitations($publicationId, $citationsString);
$publication->setData('citationsRaw', $citationsString);
}
Thanks a mil @Vitaliy . I’ll probably use these changes as have to reload a few journals in the next few days, but I’ll keep an eye on the github issue and pull requests to see the final diff. Let me know if you want me to do more testing.
Eoghan
@eocarragain, I’ve made a PR, it isn’t merged yet. It would be great if you test it. This PR is against the master branch but it should act the same in the 3.2.1 version.
Tested with your pull request @Vitaliy & all looks good. Thanks!
Thank you for help. We can see It changes in new version ojs 3.2.1-2 ?
Hi @dmasta,
It will be included in OJS 3.3