Import/Export Error "The file could not be uploaded or revised."

Hello, When importing an xml file, using native xml plugin, I get a pop up saying “The file could not be uploaded or revised.” I have made sure that php is configured to handle file uploads and I am still getting this error. Also the exports have the following error:

Validation errors:

Element ‘{http://pkp.sfu.ca}authors’: This element is not expected. Expected is one of ( {http://pkp.sfu.ca}id, {http://pkp.sfu.ca}title ).

Element ‘{http://pkp.sfu.ca}authors’: This element is not expected. Expected is one of ( {http://pkp.sfu.ca}id, {http://pkp.sfu.ca}title ).

Element ‘{http://pkp.sfu.ca}authors’: This element is not expected. Expected is one of ( {http://pkp.sfu.ca}id, {http://pkp.sfu.ca}title ).

Invalid XML:

when i try to export articles. Here is what my error log has:

[Tue Jun 04 17:13:42.921099 2019] [php7:notice] [pid 29493] [client 129.120.92.250:54996] PHP Notice: tempnam(): file created in the system’s temporary directory in /var/www/html/ojs312/lib/pkp/classes/file/TemporaryFileManager.inc.php on line 90, referer: https://journals./index.php/sample/management/importexport/plugin/NativeImportExportPlugin
[Tue Jun 04 17:13:42.921208 2019] [php7:warn] [pid 29493] [client 129.120.92.250:54996] PHP Warning: move_uploaded_file(/var/www/html/ojs312/uploads/temp/xmlqRWlpE): failed to open stream: Permission denied in /var/www/html/ojs312/lib/pkp/classes/file/FileManager.inc.php on line 122, referer: https://journals/index.php/sample/management/importexport/plugin/NativeImportExportPlugin
[Tue Jun 04 17:13:42.921217 2019] [php7:warn] [pid 29493] [client 129.120.92.250:54996] PHP Warning: move_uploaded_file(): Unable to move ‘/tmp/phpbgrYee’ to ‘/var/www/html/ojs31/uploads/temp/xmlqRWlpE’ in /var/www/html/ojs312/lib/pkp/classes/file/FileManager.inc.php on line 122, referer: https://journals/index.php/sample/management/importexport/plugin/NativeImportExportPlugin
[Tue Jun 04 17:17:54.431522 2019] [php7:warn] [pid 32454] [client 129.120.92.250:51804] PHP Warning: Declaration of SubmissionKeywordEntryDAO::getByControlledVocabId($controlledVocabId, $rangeInfo = NULL) should be compatible with ControlledVocabEntryDAO::getByControlledVocabId($controlledVocabId, $rangeInfo = NULL, $filter = NULL) in /var/www/html/ojs312/lib/pkp/classes/submission/SubmissionKeywordEntryDAO.inc.php on line 20, referer: https://journalsindex.php/sample/management/importexport/plugin/NativeImportExportPlugin
[Tue Jun 04 17:17:54.434467 2019] [php7:warn] [pid 32454] [client 129.120.92.250:51804] PHP Warning: Declaration of SubmissionAgencyEntryDAO::getByControlledVocabId($controlledVocabId, $rangeInfo = NULL) should be compatible with ControlledVocabEntryDAO::getByControlledVocabId($controlledVocabId, $rangeInfo = NULL, $filter = NULL) in /var/www/html/ojs312/lib/pkp/classes/submission/SubmissionAgencyEntryDAO.inc.php on line 44, referer: https://journals/index.php/sample/management/importexport/plugin/NativeImportExportPlugin
[Tue Jun 04 17:17:54.438589 2019] [php7:warn] [pid 32454] [client 129.120.92.250:51804] PHP Warning: Declaration of SubmissionDisciplineEntryDAO::getByControlledVocabId($controlledVocabId, $rangeInfo = NULL) should be compatible with ControlledVocabEntryDAO::getByControlledVocabId($controlledVocabId, $rangeInfo = NULL, $filter = NULL) in /var/www/html/ojs312/lib/pkp/classes/submission/SubmissionDisciplineEntryDAO.inc.php on line 44, referer: https://journals/index.php/sample/management/importexport/plugin/NativeImportExportPlugin
[Tue Jun 04 17:17:54.440065 2019] [php7:warn] [pid 32454] [client 129.120.92.250:51804] PHP Warning: Declaration of SubmissionSubjectEntryDAO::getByControlledVocabId($controlledVocabId, $rangeInfo = NULL) should be compatible with ControlledVocabEntryDAO::getByControlledVocabId($controlledVocabId, $rangeInfo = NULL, $filter = NULL) in /var/www/html/ojs312/lib/pkp/classes/submission/SubmissionSubjectEntryDAO.inc.php on line 44, referer: https://journalsindex.php/sample/management/importexport/plugin/NativeImportExportPlugin
[Tue Jun 04 17:18:03.743482 2019] [php7:notice] [pid 32454] [client 129.120.92.250:51804] ojs2: Could not convert selected objects., referer: https://journals/index.php/sample/management/importexport/plugin/NativeImportExportPlugin

Any help is appreciated. thank you.

Hi @Jeremy_Jones,

There are at least two problems here. The first is the validation error:

Element ‘{http://pkp.sfu.ca}authors’: This element is not expected. Expected is one of ( {http://pkp.sfu.ca}id, {http://pkp.sfu.ca}title ).

This says that the XML that you’re trying to import doesn’t conform to the specification that OJS expects. At a glance, it looks like it’s missing article ID and title information. I’d suggest checking the XML stylesheet to make sure the document is valid; you can use external tools to validate the XML before trying to import it (which might be a little less cumbersome than using uploads to OJS to validate).

The second problem is a file permission problem:

Warning: move_uploaded_file(/var/www/html/ojs312/uploads/temp/xmlqRWlpE): failed to open stream: Permission denied in /var/www/html/ojs312/lib/pkp/classes/file/FileManager.inc.php on line 122, referer: https://journals/index.php/sample/management/importexport/plugin/NativeImportExportPlugin

This suggests that the permissions in your uploads directory do not permit OJS to store files there. See How should file permissions be set? for details.

At a glance, I suspect your files_dir (in config.inc.php) is configured dangerously – see docs/README under “Recommended Configuration” for more information about this. It may lead to malicious uploads being used to attack your installation. I would recommend fixing this immediately.

Regards,
Alec Smecher
Public Knowledge Project Team

Ok, thank you. I have some progress. I am still getting the validation errors from the exported XML. In in particular:

Validation errors:

  • Element ‘{http://pkp.sfu.ca}revision’, attribute ‘user_group_ref’: The attribute ‘user_group_ref’ is not allowed.

Does the export XML not use the same rules for importing. I do not understand why the 2 are not matching up. Can I just remove the attributes on these tags?

Hi @Jeremy_Jones,

Can you clarify what you’re doing with the XML? For example, are you generating it from one version of OJS, and importing it into another?

Regards,
Alec Smecher
Public Knowledge Project Team

Hello,

Yes, this has been more complicated than anticipated. I just found out that the export files that I received are from version 3.1.0.1 and I’m running version 3.1.2 and there appears to be differences in the way the xml was generated. I’m requesting that the other end update their instance and regenerate the xml files. I was under the impression that we were both on the latest version and it was a simple import from their instance to ours. If they cannot update, is there a way to convert the file?

Hi @Jeremy_Jones,

The best way to know how the format has changed between releases is to compare the XML schemas, which describe the XML format. Each release of OJS comes with two relevant schema files:

  • lib/pkp/plugins/importexport/native/pkp-native.xsd (for the shared schema components that are used by e.g. both OJS and OMP)
  • plugins/importexport/native/native.xsd (for OJS-specific additions to this)

I’d suggest comparing these two files between the different versions. This is easy if you use git:

diff --git a/plugins/importexport/native/pkp-native.xsd b/plugins/importexport/native/pkp-native.xsd
index d24c47e..53fabaa 100644
--- a/plugins/importexport/native/pkp-native.xsd
+++ b/plugins/importexport/native/pkp-native.xsd
@@ -3,8 +3,8 @@
 <!--
   * plugins/importexport/native/pkp-native.xsd
   *
-  * Copyright (c) 2014-2018 Simon Fraser University
-  * Copyright (c) 2003-2018 John Willinsky
+  * Copyright (c) 2014-2019 Simon Fraser University
+  * Copyright (c) 2003-2019 John Willinsky
   * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
   *
   * Schema describing native XML import/export elements shared across PKP applications
@@ -90,6 +90,7 @@
 					<sequence>
 						<element ref="pkp:id" minOccurs="0" maxOccurs="unbounded" />
 						<element name="name" type="pkp:localizedNode" minOccurs="1" maxOccurs="unbounded" />
+						<element name="submission_file_ref" type="pkp:submission_file_ref" minOccurs="0" maxOccurs="1" />
 						<group ref="pkp:fileContents" />
 					</sequence>
 					<attribute name="direct_sales_price" type="decimal" />
@@ -170,9 +171,8 @@
 	<!-- An identity (e.g. user, author) -->
 	<complexType name="identity" abstract="true">
 		<sequence>
-			<element name="firstname" type="string" />
-			<element name="middlename" type="string" minOccurs="0" maxOccurs="1" />
-			<element name="lastname" type="string" />
+			<element name="givenname" type="pkp:localizedNode" minOccurs="1" maxOccurs="unbounded" />
+			<element name="familyname" type="pkp:localizedNode" minOccurs="0" maxOccurs="unbounded" />
 			<element name="affiliation" type="pkp:localizedNode" minOccurs="0" maxOccurs="unbounded" />
 			<element name="country" type="string" minOccurs="0" maxOccurs="1" />
 			<element name="email" type="string" />

…and…

diff --git a/plugins/importexport/native/native.xsd b/plugins/importexport/native/native.xsd
index 2ae80d9..e812047 100644
--- a/plugins/importexport/native/native.xsd
+++ b/plugins/importexport/native/native.xsd
@@ -3,8 +3,8 @@
 <!--
   * plugins/importexport/native/native.xsd
   *
-  * Copyright (c) 2014-2018 Simon Fraser University
-  * Copyright (c) 2003-2018 John Willinsky
+  * Copyright (c) 2014-2019 Simon Fraser University
+  * Copyright (c) 2003-2019 John Willinsky
   * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
   *
   * Schema describing native XML import/export elements specific to OJS
@@ -25,6 +25,7 @@
 					<sequence>
 						<element ref="pkp:issue_identification" minOccurs="0" maxOccurs="1" />
 						<element maxOccurs="1" minOccurs="0" name="pages" type="string" />
+						<element ref="pkp:covers" minOccurs="0" maxOccurs="1" />
 					</sequence>
 					<attribute name="section_ref" type="string" use="required" />
 					<attribute name="seq" type="int" />
@@ -118,7 +119,7 @@
 			<element name="open_access_date" type="date" minOccurs="0" maxOccurs="1" />
 			<!-- sub elements -->
 			<element ref="pkp:sections" minOccurs="1" maxOccurs="1" />
-			<element ref="pkp:issue_covers" minOccurs="0" maxOccurs="1" />
+			<element ref="pkp:covers" minOccurs="0" maxOccurs="1" />
 			<element ref="pkp:issue_galleys" minOccurs="0" maxOccurs="1" />
 			<element ref="pkp:articles" minOccurs="1" maxOccurs="1" />
 		</sequence>
@@ -160,7 +161,7 @@
 		</sequence>
 	</complexType>
 
-	<element name="issue_covers">
+	<element name="covers">
 		<complexType>
 			<sequence>
 				<element ref="pkp:cover" minOccurs="1" maxOccurs="unbounded" />

There isn’t a toolset to adapt XML files between versions, but if I were doing this, I’d either try to upgrade the older of the two versions, or manually adapt the files. (Changes are not major.)

Regards,
Alec Smecher
Public Knowledge Project Team