OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



full paper export to XML

OCS development discussion, enhancement requests, third-party patches and plug-ins.

Moderators: jmacgreg, michael

Forum rules
Developer Resources:

Documentation: The OJS Technical Reference and the OJS API Reference are both available from the OJS Documentation page. While these are OJS-specific, the OCS codebase is similar enough to OJS they should be of help. There is also an [url=http://pkp.sfu.ca/ocs_documentation[/url]OCS Documentation[/url] page with some more general documentation that might also be of interest.

Git: You can access our public Git Repository here. Comprehensive Git usage instructions are available on the wiki.

Bugzilla: You can access our Bugzilla report tracker here.

Search: You can use our Google Custom Search to search across our main website, the support forum, and Bugzilla.

Questions and discussion are welcome, but if you have a workflow or usability question you should probably post to the OCS Conference Support and Discussion subforum; if you have a technical support question, try the OCS Technical Support subforum.

full paper export to XML

Postby novakmartin » Fri May 03, 2013 11:36 pm

Hi, I am trying to create a function to export a full paper text in XML in the XML export plugin. I have managed to create the function, but I am unable to get the file contents correctly out.

Here is the code

Code: Select all
$root =& XMLCustomWriter::createElement($doc, 'full_paper_file');

import('file.PaperFileManager');
$paperFileManager = new PaperFileManager($paper->getId());
$fileNode =& XMLCustomWriter::createElement($doc, 'file');
XMLCustomWriter::appendChild($root, $fileNode);
      
$embedNode =& XMLCustomWriter::createChildWithText($doc, $fileNode, 'embed', base64_encode($paperFileManager->readFile($paper->getFileId())));

XMLCustomWriter::setAttribute($embedNode, 'encoding', 'base64');
XMLCustomWriter::setAttribute($embedNode, 'mime_type', 'application/pdf');



The function crashed at the $embedNode ... line, the $paper->getFileId() does not get the nothing. If I use getPaperId() is get correctly the paper ID. The function should embed the whole paper file in the latest revision in the xml file. Please help. Thanks
novakmartin
 
Posts: 2
Joined: Fri May 03, 2013 11:27 pm

Re: full paper export to XML

Postby asmecher » Tue May 07, 2013 2:42 pm

Hi novakmartin,

Check your error logs; it's likely that you hit a PHP memory limit or something similar when encoding the file contents.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8868
Joined: Wed Aug 10, 2005 12:56 pm

Re: full paper export to XML

Postby novakmartin » Thu May 09, 2013 11:17 pm

I have found a working solution. One of the problems was that the paper have not been assigned to directors, so the getFileId function did not return anything.
Here goes the working code

Code: Select all
function &generateFullPaperFile(&$doc, &$schedConf, &$paper) {
      $root =& XMLCustomWriter::createElement($doc, 'full_paper_file');

      import('file.PaperFileManager');
      $paperFileManager = new PaperFileManager($paper->getId());
      
      $fileNode =& XMLCustomWriter::createElement($doc, 'file');
      XMLCustomWriter::appendChild($root, $fileNode);

      // this works only is the papers are already assigned to Directors, i.e. in director directory
      $embedNode =& XMLCustomWriter::createChildWithText($doc, $fileNode, 'embed', base64_encode($paperFileManager->readFile($paper->getDirectorFileId())));      
      XMLCustomWriter::setAttribute($embedNode, 'encoding', 'base64');
      XMLCustomWriter::setAttribute($embedNode, 'mime_type', 'application/pdf'); /*application/pdf*/
      
      return $root;


This is then called from function &generatePaperDom in NativeExportDom.inc.php


Code: Select all
/* --- Full Paper Files --- */
         $fullPAP =& NativeExportDom::generateFullPaperFile($doc, $schedConf, $paper);
         if ($fullPAP !== null) XMLCustomWriter::appendChild($root, $fullPAP);
         unset($fullPAP);


Now the generated .xml file contains the full paper text.
novakmartin
 
Posts: 2
Joined: Fri May 03, 2013 11:27 pm


Return to OCS Development

Who is online

Users browsing this forum: No registered users and 2 guests