How can I modify the script importing a XML file

In an earlier query I posted (https://forums.zotero.org/discussion/93336/importing-via-xml-additional-strange-behaviour) it was suggested that I could modify the script for importing a XML file but I cannot find what I should modify and it would be great to receive some pointers.

The issue I've been experiencing is: I have created a XML file (from Reference Manager) and, so far as I can tell, all the non-empty fields of each record are saved as expected. However, when I import into Zotero I find that two fields are not imported. These are tagged 'User Def 2' and 'User Def 3' in Reference Manager and from the behaviour of the other 'User Def ?' fields I would have expected them to end up tagged as 'custom2' and custom3' in the 'The following values have no corresponding Zotero field' Note in Zotero. The 'User Def 1/4/5' fields are imported and tagged 'custom1/4/5' in this Note field along with some other bits and bobs.

Many thanks for any assistance,

Anthony
  • Have you checked that they are in the XML file?

    What you would need to modify is the EndnoteXML.js file in the translators folder in the Zotero data folder, but that should indeed just add custom2, custom3 etc to a note if they exist
  • Yes, the RM fields are in the XML file... I created a dummy record in RM and this is the relevant section in the XML file. So 'custom1/4/5' are imported but 'custom2/3' are not.

    -
    User Def 1 field


    -
    User Def 2 field


    -
    User Def 3 field


    -
    User Def 4 field


    -
    User Def 5 field


    I'll take a look at the EndnoteXML.js in a jiffy.

    Many thanks,

    Anthony
  • Sorry, that didn't work so well... there should have been part of a XML in my previous comment... I didn't expect the opening and closing angle brackets to be eaten.

  • surround the xml with <code>xml here</code>
  • Many thanks @emilianoeheyns, that's helpful.

    Here's the XML I tried to insert earlier.



    <custom1>
    <style font="default" face="normal">User Def 1 field</style>
    </custom1>

    <custom2>
    <style font="default" face="normal">User Def 2 field</style>
    </custom2>

    <custom3>
    <style font="default" face="normal">User Def 3 field</style>
    </custom3>

    <custom4>
    <style font="default" face="normal">User Def 4 field</style>
    </custom4>

    <custom5>
    <style font="default" face="normal">User Def 5 field</style>
    </custom5>



    I've had a look at the EndnoteXML.js file and it's going to take me a while to figure out what's going on... but as I don't really understand JavaScript that's a long shot. It's strange that some of these fields are imported (although put into a Child Note) while some aren't and the text is lost.

    Thanks for the comments so far,

    Anthony
  • Could you put your full dummy record on pastebin.com or a similar site and link to it from here?
  • I think I did what you requested and here's the link: https://pastebin.com/Xacmd99w. There's a single record with all the fields I use populated with some relevant text.

    Many thanks for your assistance with this.
  • Yes, that's perfect. I'll try to take a look ASAP, post back here if you haven't heard back in a week
  • Hi -- I'll put in a general fix, but that might take some time to make it through. For a quick fix, find the else if condition starting in line 670 and replace with
    } else if (field.search(/custom[237]/) != -1 &&
    (newItem.itemType == "book" || newItem.itemType == "bookSection" || newItem.itemType == "journalArticle") &&
    node.textContent.search(/PMC\d+/i) != -1) {
    //it'd be nice if we could do PMIDs as well, but doesn't look like they're mapped and we can't test for them reliably
    newItem.extra = (newItem.extra || '') +
    "PMCID: " + node.textContent.match(/PMC\d+/i)[0] + "\n";


    (make sure you get the closing & opening {} right.

    By means of explanation, we've seen PMCID in those fields, which we want to import, but the test currently leads them to be ignored, which is a bug
  • Many thanks, that seems to have worked... as you said, I had to keep track of the {} and got it wrong the first time! Once corrected, the import worked fine so far as I could tell.
    I'm now going to do some larger scale tests before moving on to a 'final' import and I'm looking forward to being able to use Zotero as my sole bibliographic manager. Glad I was able to find a bug ;-{} .
    Take care and thanks again.
Sign In or Register to comment.