Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Validation of XML Sitemap urlset with xhtml:link inside url element

I am trying to create a sitemap such as the below and I get this error:

 <?xml version="1.0" encoding="UTF-8"?>
  <urlset
    xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" 
    xmlns:xhtml="http://www.w3.org/1999/xhtml" 
    xhtml:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
        http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
     <url>
         <loc>http://www.something.com/something</loc>
         <xhtml:link rel="alternate" hreflang="en-us" href="http://www.something.com/something" />
     </url>
 </urlset>

Error:

http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"> ^ Error 1866: Element '{http://www.sitemaps.org/schemas/sitemap/0.9}urlset', attribute '{http://www.w3.org/1999/xhtml}schemaLocation': The attribute '{http://www.w3.org/1999/xhtml}schemaLocation' is not allowed. on line: 3

'{http://www.w3.org/1999/xhtml}link': No matching global element declaration available, but demanded by the strict wildcard.

Please advice. Thank you.

like image 964
Stackoverflow User Avatar asked Mar 24 '16 04:03

Stackoverflow User


1 Answers

There are two issues in this document:

  1. The schemaLocation attribute must be in the XML Schema Instance namespace.

  2. The url element is invalid, because its definition says processContents="strict" and the schema for XHTML was missing so that there was no xhtml:link declaration in scope.

    <?xml version="1.0" encoding="UTF-8"?>
    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:xhtml="http://www.w3.org/1999/xhtml"
        xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
        http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd
        http://www.w3.org/1999/xhtml
        http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd">
      <url>
        <loc>http://www.something.com/something</loc>
        <xhtml:link rel="alternate" hreflang="en-us" href="http://www.something.com/something" />
      </url>
    </urlset>
    
like image 76
Ghislain Fourny Avatar answered Sep 24 '22 00:09

Ghislain Fourny