ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

White space at top of Atom feed

August 30, 2007 5:51pm

Subscribe [2]
  • #1 / Aug 30, 2007 5:51pm

    Kenn Christ

    26 posts

    I’ve got a line of whitespace being inserted at the top of my Atom feeds that is causing it to break. I’ve read through posts here about similar problems but none of the proposed fixes have worked for me. The feed is being sent as text/xml, the template type is “RSS page”, caching is off, I’m not using any PHP in it, and I’ve removed all whitespace from the top of the template. I’m using EE 1.6, build 20070708. I have two feeds on this site and both are broken in this way.

    Interestingly, I’ve got a testing site set up with this same EE build and the feed works fine there. Copying that template verbatim into the broken one, only changing the weblog name, doesn’t fix it, which makes no sense to me. I’ve also replaced this template with the one provided on the EE site and that still doesn’t do it.

    These are the first two lines of the template:

    {exp:rss:feed weblog="durtro"}
    <?xml version="1.0" encoding="{encoding}"?>

    The feed validator is telling me:

    * line 2, column 0: XML parsing error: <unknown>🔢0: xml declaration not at start of external entity

    And this is backed up by what I’m seeing when I fetch the feed myself:

    $ curl <a href="http://www.softblackstars.org/durtro/feed">http://www.softblackstars.org/durtro/feed</a>
    
    <?xml version="1.0" encoding="utf-8"?>
    <feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">

    The feed is located at http://www.softblackstars.org/durtro/feed

    What could be causing this?

  • #2 / Aug 30, 2007 6:01pm

    Lisa Wess

    20502 posts

    Can you try refreshing your files, basically following the build update instructions? That’ll get you on the latest build and ensure none of your files have any white space or other corruption in them.

  • #3 / Aug 30, 2007 6:31pm

    Kenn Christ

    26 posts

    Sure, I’ll give it a shot, but I won’t have time for something like this until probably tomorrow evening.

    Any idea why this is only happening on one installation out of two that came from the same original zip file?

  • #4 / Aug 30, 2007 6:36pm

    Lisa Wess

    20502 posts

    The FTP process itself can cause some strange issues during uploads, that’s why we almost always ask you to try re-uploading the files from a fresh download, to rule those problems out.

  • #5 / Aug 30, 2007 7:41pm

    Kenn Christ

    26 posts

    I don’t use FTP, but keep EE in a Subversion repository. The live site is a Subversion working copy (via ‘svn checkout’), as is my testing and development stuff.

    I’ll report back after updating to the latest build, but please feel free to toss out suggestions (this goes for anyone reading!). Thanks.

  • #6 / Aug 31, 2007 11:36am

    Kenn Christ

    26 posts

    I’ve updated EE to build 20070815 and I’m still having the same problem.

    Other things I’ve tried without success since yesterday are recreating the template in the EE control panel, trying both the RSS and XML page types, and starting over using the provided feed templates, trying both Atom and RSS 2.0.

    I’ve checked for unparsed variables in the generated feed source that might indicate an EE syntax problem on my end but everything looks ok.

    What’s the next thing to look at? What other information can I give you that might help?

  • #7 / Aug 31, 2007 12:11pm

    Derek Jones

    7561 posts

    Check for whitespace in your path.php, index.php, and config.php files.  If PHP errors are hidden, one of these files could be introducing whitespace prior to ExpressionEngine’s output.  If that doesn’t work, just for kicks, try this in your template as the first line (though it really shouldn’t matter):

    {exp:rss:feed weblog="durtro"}<?xml version="1.0" encoding="{encoding}"?>
  • #8 / Aug 31, 2007 12:39pm

    Kenn Christ

    26 posts

    Removing the whitespace from the top of the feed template was the first thing I tried, and you’re right, that had no effect.

    BUT, there was a newline at the end of config.php and removing that fixed the feeds!  Thank you. One of the site’s primary reasons for existence was to provide one of these feeds, so it being broken really had me pulling my hair out. Thanks again.

  • #9 / Aug 31, 2007 1:17pm

    Derek Jones

    7561 posts

    Awesome, glad we were able to help you find it.  You may wish to inquire with your host about turning PHP errors on (the display_errors directive).  ExpressionEngine will not output errors to the general public unless you have it set to do so in your Output and Debugging preferences, so it is secure, and in this particular case, you would have seen an error saying that “Cannot modify headers ... output began in /path/to/config.php line X”, which would have led you directly to the problem.

  • #10 / Aug 31, 2007 1:49pm

    Kenn Christ

    26 posts

    I am my own web host 😊  I have display_errors off on the public-facing server for obvious reasons, but thought I had it enabled in my testing environments. I’ll have to double check.

    Thanks again.

  • #11 / Aug 31, 2007 2:07pm

    Derek Jones

    7561 posts

    Unless you have other PHP scripts on your site that do not set their own error levels, ExpressionEngine is perfectly fine to run with display_errors on, so long as you do not have PHP and MySQL errors output to guests in your Output and Debugging preferences.  I run all of my sites with that server directive on, and set to display errors to Super Admins only.

  • #12 / Nov 07, 2007 7:05am

    123454329

    144 posts

    derek:
    i seem to have a similar issue - please lend me a hand.

    i run 2 separate feeds on my blog (as i do not know of a solution to integrate them in “one unified feed”):
    blog feed
    gallery feed

    with “php_errors enabled” both display errors:

    blog feed:
    
    error on line 286 at column 19: Extra content at the end of the document
    gallery feed:
    
    error on line 5 at column 6: XML declaration allowed only at the start of the document

    feed validator validates the blog feed but “doesn’t the gallery feed”:
    http://validator.w3.org/feed/

    here’s the code for the templates:

    {assign_variable:master_weblog_name="de|en"}
    
    {exp:rss:feed weblog="{master_weblog_name}"}
    
    <?xml version="1.0" encoding="{encoding}"?>
    <feed xmlns="http://www.w3.org/2005/Atom" xml:lang="{weblog_language}">
    
        <title type="text">{exp:xml_encode}Thomas' (Blog){/exp:xml_encode}</title>
        <subtitle type="text">{exp:xml_encode}{weblog_name}:{weblog_description}{/exp:xml_encode}</subtitle>
        <link rel="alternate" type="text/html" href="{weblog_url}" />
        <link rel="self" type="application/atom+xml" href="http://mydomain.com/feed/atom" />
        <updated>{gmt_edit_date format='%Y-%m-
T;%H:%i:&#xsZ;'}</updated>
        <id>tag:{trimmed_url},{gmt_date format="%Y:%m:%d"}</id>
    
    {exp:weblog:entries weblog="{master_weblog_name}" limit="15" rdf="off" dynamic_start="on" disable="member_data|trackbacks"}
        <entry>
          <title>{exp:xml_encode}{title}{/exp:xml_encode}</title>
          <link rel="alternate" type="text/html" href="{url_title_path=blog/filed}" />
          <id>tag:{trimmed_url},{gmt_entry_date format="%Y"}:{relative_url}/{weblog_id}.{entry_id}</id>
          {gmt_entry_date format="%Y-%m-
T;%H:%i:&#xsZ;"}</published>
          <updated>{gmt_edit_date format='%Y-%m-
T;%H:%i:&#xsZ;'}</updated>
          <author>
                <name>{author}</name>
                <email>{email}</email>
                {if url}<uri>{url}</uri>{/if}
          </author>
    {categories}
          <category term="{exp:xml_encode}{category_name}{/exp:xml_encode}"
            scheme="{path=blog/filed}"
            label="{exp:xml_encode}{category_name}{/exp:xml_encode}" >{/categories}
          <content type="html"><![CDATA[
            {body} {extended}
          ]]></content>
        </entry>
    {/exp:weblog:entries}
    
    </feed>
    
    {/exp:rss:feed}
    {assign_variable:gallery_name="gallery"}
    {assign_variable:gallery_template="gallery"}
    {assign_variable:master_weblog_name="en"}
    {assign_variable:atom_feed_path="feed/atom_gallery"}
    {exp:rss:feed weblog="{master_weblog_name}"}<?xml version="1.0" encoding="{encoding}"?>
    <feed xmlns="http://www.w3.org/2005/Atom" xml:lang="{weblog_language}">
    
    <title type="text">Thomas' (Photo)</title>
    <subtitle type="text">{exp:xml_encode}{weblog_description}{/exp:xml_encode}</subtitle>
    <link rel="alternate" type="text/html" href="{weblog_url}" />
    <link rel="self" type="application/atom+xml" href="{path={atom_feed_path}}" />
    <updated>{gmt_edit_date format='%Y-%m-
T;%H:%i:&#xsZ;'}</updated>
    <id>tag:{trimmed_url},{gmt_date format="%Y:%m:%d"}</id>
    
    {exp:gallery:entries gallery="{gallery_name}" orderby="entry_date" rows="10" columns="1"} 
    {entries}
    {row}
    <entry>
    <title>{exp:xml_encode}{title}{/exp:xml_encode}</title>
    <link rel="alternate" type="text/html" href="{id_path={gallery_template}/image-full}" />
    <id>tag:{trimmed_url},{gmt_date format="%Y"}:{url}/{gallery_id}.{entry_id}</id>
    {gmt_entry_date format="%Y-%m-
T;%H:%i:&#xsZ;"}</published>
    <updated>{gmt_edit_date format='%Y-%m-
T;%H:%i:&#xsZ;'}</updated>
    <author>
    <name>{author}</name>
    <email>{email}</email>
    </author>
    <category term="{category}" 
    scheme="{path=gallery/index}" 
    label="{category}" >
    <content type="html"><![CDATA[<a href="http://{id_path={gallery_template}/image-full}">_{thumb_url}</a><strong>{title}</strong>
    {caption}]]>
    </content>
    </entry>
    
    {/row}
    {/entries}
    {/exp:gallery:entries}
    
    </feed>
    {/exp:rss:feed}


    i have tried to follow all your instructions in this thread but can’t figure it out.

    thank you.

  • #13 / Nov 07, 2007 10:22am

    Robin Sowell

    13255 posts

    I’m not thinking those look like php errors.  xml perhaps?  As to the gallery- I’d probably hard code the channel, but if you want to do it that way, try eliminating the whitespace introduced by the breaks after the globals:

    {assign_variable:gallery_name="gallery"}{assign_variable:gallery_template="gallery"}{assign_variable:master_weblog_name="en"}{assign_variable:atom_feed_path="feed/atom_gallery"}{exp:rss:feed weblog="{master_weblog_name}"}<?xml etc…

    Make sense?  Let’s see what that gets us.

  • #14 / Nov 07, 2007 10:45am

    123454329

    144 posts

    hey robin:
    i have uploaded the “atom_gallery” template-file for your information here:

    download .zip

    i just can’t find whitespace in it … and yes, i had tried to hard-code the globals but with no positive result. what am i missing?

    ***

    i have tried this variant:

    {exp:rss:feed weblog="en"}<?xml version="1.0" encoding="{encoding}"?>
    <feed xmlns="http://www.w3.org/2005/Atom" xml:lang="{weblog_language}">
    <title type="text">Thomas (Photo)</title>
    <subtitle type="text">{exp:xml_encode}{weblog_description}{/exp:xml_encode}</subtitle>
    <link rel="alternate" type="text/html" href="{weblog_url}" />
    <link rel="self" type="application/atom+xml" href="http://mydomain.com/feed/atom_gallery" />
    <updated>{gmt_edit_date format='%Y-%m-
T;%H:%i:&#xsZ;'}</updated>
    <id>tag:{trimmed_url},{gmt_date format="%Y:%m:%d"}</id>
    {exp:gallery:entries gallery="gallery" orderby="entry_date" rows="10" columns="1"} 
    {entries}{row}<entry>
    <title>{exp:xml_encode}{title}{/exp:xml_encode}</title>
    <link rel="alternate" type="text/html" href="{id_path=gallery/image-full}" />
    <id>tag:{trimmed_url},{gmt_date format="%Y"}:{url}/{gallery_id}.{entry_id}</id>
    {gmt_entry_date format="%Y-%m-
T;%H:%i:&#xsZ;"}</published>
    <updated>{gmt_edit_date format='%Y-%m-
T;%H:%i:&#xsZ;'}</updated>
    <author>
    <name>{author}</name>
    <email>{email}</email>
    </author>
    <category term="{category}" 
    scheme="{path=gallery}" 
    label="{category}" >
    <content type="html"><![CDATA[<a href="http://{id_path=gallery/image-full}">_{thumb_url}</a><strong>{title}</strong>
    {caption}]]>
    </content>
    </entry>{/row}{/entries}
    {/exp:gallery:entries}
    </feed>{/exp:rss:feed}

    it is throwing errors about this line of code:

    <updated>{gmt_edit_date format='%Y-%m-
T;%H:%i:&#xsZ;'}</updated>

    plus, all entries show the same publish and update date - which is not right as they were published on different dates.

    sorry: this stuff is way too much for me!!

  • #15 / Nov 07, 2007 11:20am

    Derek Jones

    7561 posts

    Try adding the dynamic_start= parameter to your weblog entries tag in the same manner that you are using it in your weblog feed template.  Your report has revealed a small bug that when this parameter is not used, extra whitespace is not being properly removed from the template before outputting to the browser.  This will be fixed in the next release, but adding that parameter should fix you now.

    Edit: Whoops, you aren’t using a weblog entries tag.  Look at Robin’s solution that doesn’t use the RSS module (which really isn’t needed for the type of feed you want); you can work in that direction if you cannot wait for the bugfix to be released.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases