Jump to content

Whitespace at the beginning of the source code leads to problems


Juergen
 Share

Recommended Posts

Hello @ all,

I couldn´t  find the cause why I am always getting a white space at the beginning of my source code.

 <!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="de"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8" lang="de"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9" lang="de"> <![endif]-->

As you can see there is a white space before the doctype declaration (<!DOCTYPE html>).

This leads in pages with RSS-markup to errors, because whitespaces are not allowed there. I have not included anything before!!

I dont know when this problem started. I use the sitemap module on my site which produce a XML-page. This module was working for a long time without problems. But in the past I always get errors because of the whitespace.

It seems that the whitespace problem started either with an update or with the installation of a module. Unfortunately I cannot figure out what the cause could be.

Has someone discovered the same behaviour on his site or has someone an idea how to find out the cause of this problem.

Best regards Jürgen

Link to comment
Share on other sites

Afternoon Jürgen,

A million and one possible causes:

  • a hook prepending output to anything rendered
  • a rouge echo chucking out a space
  • a simple error in the rendering page (that includes the doctype declaration)
  • a space in an including tag
  • etc. etc.

Really without looking at code and systematically ruling out - or somebody who had the same issue with similar modules there's not a lot of hope for a quick fix.

Phil

EDIT:

If you can find the template or include file that includes the line

<!DOCTYPE html>

that would be a good place to start the hunt. Most likely a head.inc or main.inc

Link to comment
Share on other sites

Thank you for your prompt answere!!

Yes I know that this could be tricky to find out.

As I mentioned I use the sitemap module to create a sitemap in a xml format. This module produces a pure sitmap.xml file. So in this case there cannot be included something before.

This module has worked for a long time but now there is also a whitespace at the beginning of the XML opening tag (http://www.juergen-kern.at/sitemap.xml). So in this case I have no influence on creating the output code (no include errors and so on) . This module produce the xml markup code on its own but the whitespace is still there.

Link to comment
Share on other sites

is it possible that this is an encoding error? Which sitemap module do you use? This one?

https://processwire.com/talk/topic/799-module-xml-sitemap/

What happens if you place a die('test'); in the renderSitemap method? Is a whitespace included as well? Anything in the error.log perhaps?

My approach would be: Die() whereever you can and try to isolate the problem. good luck!

Link to comment
Share on other sites

  • 3 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...