When I try to access the sitemap in my browser I got the following error. I however saw that Google Webmaster tools did not have any complaints with the actual sitemap format. I was also able to download the sitemap using wget.

The error while opening the xml in a browser was

Error loading stylesheet: An XSLT stylesheet does not have an XML mimetype:http://www.benzinga.com/home/benzinga/benzinga.com/scripts/sitemap.xsl

The xsl line in the sitemap said

href="/home/benzinga/benzinga.com/scripts/sitemap.xsl"

I checked out and found that the $base_url was not set in settings.php and set that up and the problem disappeared.

I hope this helps somebody.

Comments

Dave Reid’s picture

That's really odd. I can modify this so it uses the base_url option in the XML sitemap settings, but since it uses url() to generate a local path, it probably won't even be used. Odd... Did you have any other problems with links in your actual site being messed up before you changed $base_url?

Dave Reid’s picture

FYI: The base_url tip is already documented in the Known issues.

anoopjohn’s picture

Not quite :-). The known issues reports the result of not setting base_url as incorrect urls in the sitemap and not related to the specific xsl error. I have added it to the list though.

Dave Reid’s picture

Status: Active » Fixed

I added the base_url from the xmlsitemap settings page when the link to the XSL is created, so this should help incase anyone else experiences this.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

dbeall’s picture

Version: 6.x-2.0-unstable4 » 6.x-2.0-unstable5
Category: bug » support
Priority: Normal » Minor
Status: Closed (fixed) » Active

I am getting this same error on 2 sites with unstable5 since upgrade. The base URL in the settings.php is un-commented and the URL is entered, the base URL in the xmlsitemap settings is correct. Is there something maybe in a table amiss...
any ideas would be really neat as I am not really a programmer person, but not afraid to crack open the hood with a idea of what to look for.
thanks.. dave

dbeall’s picture

sorry,, scratch that. Now it is giving page not found on one site and on the other site is giving the error.
Error loading stylesheet: An XSLT stylesheet does not have an XML mimetype:
http://www.davebeall.com/sitemap.xsl which shows sitemap with nothing in it yet
http://www.davebeall.com/sitemap.xml shows the error.
I don't understand why the url is .xsl, when it should be .xml
well, i guess we don't need to see it, as long as the search engines can see it.

dbeall’s picture

Status: Active » Closed (fixed)

sorry number 2.. the cron ran and fixed one site, so this is a user is dummy situation.
change back to closed...

Dave Reid’s picture

Status: Closed (fixed) » Fixed

Hah. Glad to know the module was able to fix itself. Yay?! The sitemap.xsl is just like an 'XML stylesheet' to make sitemap.xml prettier for you to read. You'd see that the source code of sitemap.xml was still perfectly fine and good. That's odd that http://www.davebeall.com/sitemap.xsl is sending a Content-type: text/html header and not the proper application/xml type, which would fix this 'warning'. Maybe it got cached wrong?

function xmlsitemap_output_xsl() {
  // Read the XSL content from the file.
  $module_path = drupal_get_path('module', 'xmlsitemap');
  $xsl_content = file_get_contents($module_path . '/xsl/xmlsitemap.xsl');
  ...

  // Output the XSL content.
  drupal_set_header('Content-type: application/xml; charset=utf-8');
  drupal_set_header('X-Robots-Tag: noindex, follow');
  echo $xsl_content;
}

The headers should be cached in {cache_page} along with the the page data, so that's really odd. :/

nemsis’s picture

I had the same problem with lightpd web server, I don't know if this is the cause of these problems or not but the error was the same.
I fixed it by modifying the lightpd.conf file on my server and adding these two lines to the url.rewrite-final section.

   "^/sitemap.xml" => "/index.php?q=sitemap.xml",
   "^/sitemap.xsl" => "/index.php?q=sitemap.xsl"

I don't know if this is the correct fix but it worked for me.

dbeall’s picture

well, I never could the one other site that I upgraded to load a sitemap with u-5, but when I went back to u-4, it came back immediately(it's magic).. It's possible the upgrade to u-5 went wrong somehow.
side note:(I personally think the unstable label should be something shorter, like u-#)

Dave Reid’s picture

@dbeall: Can you provide more details? Do you get errors when you load http://mysite.com/sitemap.xsl? Is there a link to that file in your sitemap.xml path? Is the stylesheet option enabled?

It's not possible to shorten unstable since you can only use 'rc', 'beta', 'alpha', or 'unstable'. Anything else it won't let you tag it.

dbeall’s picture

I will investigate further and report back my findings. Might be a few days before I can back to it.. work is calling.

When I first went back to u-4, rebuilt sitemap, it was fine,, but u-4 is now doing the same thing after cron...
The UI link is http://www.bexleymarine.com/sitemap.xml and style sheet is enabled.
I think it's a cache issue, and may not be a problem with xmlsitemap.
I have Boost running on those 2 sites, but have cache xml disabled and the xmlsitemap excluded(sitemap.xml and sitemap.xsl).

if 'rc' is release candidate, then 'us' could be unstable.. It's just me, since my typing sucks, short is nice. No big deal, I will get used to it.

Dave Reid’s picture

Status: Fixed » Postponed (maintainer needs more info)

Thanks for looking more into this. Let me know what you find. I'll leave this as 'needs more info' for now.

Yeah, to help make sure that we don't make stupid release names, we're forced into a limited number of release types in our CVS tags. I'm fine with it if it were to prevent stuff like '6.x-2.0-OMGDONTUSEMEYET1' :)

dbeall’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

change to closed...

I finally had time to work on my sites..

I upgraded back to unstable5 and now it is fixed.

Sitemap shows as expected and is formatted for us humans too.
I don't know why it messed up before, could have been something wrong with my original move to u-5.

The site is on a less than acceptable host as the sql database is shared and on a different server than the site is... and yes, I have to run boost to use a crummy shared host for Drupal.

@ Dave Reid,
Thank You for everything

Dave Reid’s picture

Thanks for reporting back!