OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Blank line before XML declaration in XML export files

Are you responsible for making OJS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
What to do if you have a technical problem with OJS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a development question, try the OJS Development subforum.

Blank line before XML declaration in XML export files

Postby springday » Thu Jul 04, 2013 2:47 am

I've run into an error common to many PHP programs that generate XML output: A blank line before the xml declaration, which makes the file invalid. (For a short description of this error and solution strategy in Wordpress, see this link: http://feed2.w3.org/docs/error/WPBlankLine.html).

It is most likely that I produced this error by myself when I edited or patched the OJS source files. I'm running OJS 2.4.2 now, having patched step-by-step from 2.3.7. I think the problem first appeared since I patched from 2.4.1 to 2.4.2, but I'm not sure about it. The problem occurs with all kind of XML output, not just one specific plugin (I tried user export, native article export, CrossRef export).
Anyway, after many, many hours of fruitless searching I post my problem here for two reasons:

  1. I want to make sure that it's an individual error of my installation and not commonly shared with others.
  2. I am hoping for somebody who could give me an advice concerning a solution strategy.

What I have done so far:
  • I have gone through all PHP files in /classes, /pages, /plugins, /tools, /lib/pkp/classes, /lib/pkp/includes, /lib/pkp/pages, /lib/pkp/plugins, and /lib/pkp/tools with regular expressions to find line-breaks and space characters before or after the PHP declarations: "\?>[\s\l\n\r]+" and "[\s\l\n\r]+<\?php". I've found a few hazardous space characters that I eliminated. I also removed traling \n and \r characters after the "?>" even though I think that those should not be a problem by themselves. That didn't solve the problem, though.
  • Because I'm sometimes working on windows systems and sometimes on linux, and the webserver is running linux, I made sure that there's no hiccup caused by different line-breaks. I've run "dos2unix" on the webserver on all OJS files to make sure the line-breaks are consistant.
  • I've wrapped an xdebug_trace around the call to generate one xml export and manually checked through the files whose methods are used in the process. The trace was clearly showing that the printXML() function in the XMLCustomWriter of OJS was returning a correct XML file with no empty line before the XML declaration. Therefore it was useless, to wrap the output of printXML() with an additional trim(). (I had tried that as well, however, before I found the correct XML output in the trace.

I'm at a loss now and don't know what else to check. Any ideas?

Best regards,
Kai Weber
springday
 
Posts: 111
Joined: Wed Jul 25, 2012 2:56 pm
Location: Munich, Germany

Re: Blank line before XML declaration in XML export files

Postby JasonNugent » Thu Jul 04, 2013 4:40 am

Hey Kai,

Is there any indication of a "cannot send header information" error in your PHP error log? There is an obscure issue that crops up once in a while with ADOdb generating some output because of an error condition, and that happens before the headers in a lot of places are sent. Naturally, that creates output before the start of any script-generated output. It's been a while, but I think the issue is related to character encoding or connection encoding, set in your config.inc.php.

That would be another file to look at, since config.inc.php is also loaded by OJS and is commonly edited by users. There shouldn't be white space before or after the <?php ... ?> blocks.

Regards,
Jason
JasonNugent
Site Admin
 
Posts: 883
Joined: Tue Jan 10, 2006 6:20 am

Re: Blank line before XML declaration in XML export files

Postby springday » Mon Jul 08, 2013 5:12 am

Hi Jason,

thanks for your help. Looked very promising, though it didn't get my any farther until now.
I only get "Cannot modify header information - headers already sent ..." error when I enable the (very verbose) database debug output in OJS' configuration, which makes sense. With debug=Off I don't run into this error.
I also traced the execution of adodb's outp() method (line 361ff of adodb.inc.php). If the comment is relyable ("All error messages go through this bottleneck function") then I can safely say, that I have the blank line in the XML files even if there's no adodb error.
I also tried a few different settings in the config for connection_charset and database_charset (utf8 and Off) with no recognizable difference in the error logs or the XML output. I only get an error for the value spelling "utf-8" (1115: Unknown character set: 'utf-8').
Maybe I should prepare my mind for a clean new installation of OJS and manually migrate the modifications...

Best regards,
Kai
springday
 
Posts: 111
Joined: Wed Jul 25, 2012 2:56 pm
Location: Munich, Germany

Re: Blank line before XML declaration in XML export files

Postby JasonNugent » Mon Jul 08, 2013 5:51 am

Hey Kai,

One other thing you could try -- maybe do a recursive diff against a stock codebase and just look for extra lines of output? It sounds like you may have already done this, though.

Regards,
Jason
JasonNugent
Site Admin
 
Posts: 883
Joined: Tue Jan 10, 2006 6:20 am

Re: Blank line before XML declaration in XML export files

Postby springday » Mon Jul 08, 2013 10:34 am

Thanks again Jason,

I did a similar thing: installed a clean codebase of OJS 2.4.2 on a development server and copied the "suspicious" folders from the live server onto it. After every copied folder I exported some XML and so I could see that the error was coming in after copying the native importexport plugin folder, where I then found a blank line before a "<?php". No idea, how that could have escaped my regexp searches, but my problem's solved now.

Best regards,
Kai
springday
 
Posts: 111
Joined: Wed Jul 25, 2012 2:56 pm
Location: Munich, Germany

Re: Blank line before XML declaration in XML export files

Postby JasonNugent » Mon Jul 08, 2013 1:01 pm

Awesome!
JasonNugent
Site Admin
 
Posts: 883
Joined: Tue Jan 10, 2006 6:20 am


Return to OJS Technical Support

Who is online

Users browsing this forum: Baidu [Spider] and 3 guests