Native XML attribute meaning for author "id" and "seq"

Description of issue or problem I’m having:
I’ve recently taken over a project at my institution where we convert CSV metadata for journal issues into XML for import into OJS using the native XML import function. In order to update the custom program we created, I need to make changes to the program to output valid XML with OJS’s schema. I have reviewed the schema files (native.xsd and pkp-native.xsd), and I noticed that the author element now requires a seq and id attribute. So, my question is:

What does seq and id mean?

I’m assuming, for example, that seq refers to sequence. Does this attribute tell OJS what order the authors should be attributed in reference to the publication? Or does seq refer to something else?

Finally, and this is the one I am most concerned about, does the author id attribute map to the author key in the OJS database? In other words, should our custom program make sure that these ids are unique and that the id always refers to a particular author?

At the risk of over-explaining, I want to make sure that I don’t overwrite any author data by providing an id that’s already in use in OJS (if the author id attribute in the XML maps to an author primary key in OJS).

Any clarification on what exactly these two attributes mean and their importance would be greatly appreciated.


Application Version - e.g., OJS 3.1.2:
OJS 3.2.1-4

Hi @jrmitchell

From the code, those two attributes are:

$authorNode->setAttribute('seq', $author->getSequence());
$authorNode->setAttribute('id', $author->getId());

So the sequence is the order the author appears on the paper, and the id is the author_id from the authors table.

The only one that actually matters on import is sequence. It’s used to set the sequence on the author on the paper:

if ($node->getAttribute('seq')) $author->setSequence($node->getAttribute('seq'));

The author id is not actually used on import since that table column is auto increment anyway. There’s a bit of code that will look at it, and also the value in the primary contact id field on your publication and if they match, the import then sets the primary contact id on the publication to the newly fetched author id on the new database record. The new author id is returned from the insertObject method automatically.

$authorId = $authorDao->insertObject($author);

if ($node->getAttribute('id') == $publication->getData('primaryContactId')) {
        $publication->setData('primaryContactId', $author->getId());

If you want to examine the code for all of this, it’s in lib/pkp/plugins/importexport/native/filter in two main classes: (for going from authors to XML), and (for going from Native XML to an author object)


Thank you, @jnugent, for your response. I noticed that the pkp-native.xsd file for my version shows that the id attribute is required (see line 194 in particular). Does this mean, though, that the xml won’t validate on import if the author element does not have an id attribute? Or is the attribute required to be present, but it can it contain an empty string (i.e., id='')?

Finally, I noticed that, in the sample export file, the author’s sequence has a value of zero (see line 63 in particular). Does that mean that the author sequence should begin with an index of 0? For example, if I have two authors, is the first author’s sequence 0 or 1 and the second author a 1 or a 2?

I apologize for all the questions and thank you in advance for any clarification one might be able to provide.

Hi @jrmitchell

Yes, even though the id attribute is required, it’s not validated on import. It really can’t be used for anything since OJS won’t replace existing author information with imported data on the basis of a matched id. You could probably just set it to 0 if you wanted to.

For sequences, the code in the NativeXML → Author filter does:

if ($node->getAttribute('seq')) $author->setSequence($node->getAttribute('seq'));

So it will set the database field to whatever is in the XML. It actually doesn’t matter what you start counting at, because the QueryBuilder class will order according to whatever is in that field, in ascending order, when fetching authors for a publication:


Thanks, @jnugent. This is all really helpful information.