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

2

9

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.

Nose answered 24/3, 2016 at 4:32 Comment(0)
A
12

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>
    
Amoral answered 24/3, 2016 at 8:7 Comment(4)
Unbelievable how many searches I had to do to find this <urlset> combo supporting validation and the <xhtml:link>. Thank you very muchBoardman
#39451042Almost
I updated all the full qualified links to https and it worked after that.Delorisdelorme
Yeah, old thread, but thanks, this solved a puzzle for me too. Though, I trimmed the definition down to <urlset xmlns="sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="w3.org/TR/xhtml11/xhtml11_schema.html"> which was all I needed to parse the <xhtml:link> tags.Mayonnaise
G
7

Old one - but still comes up when searching. Actually the issue is that you are using xhtml:link and then you need "other" urlsets...http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd

<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd http://www.w3.org/TR/xhtml11/xhtml11_schema.html http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/TR/xhtml11/xhtml11_schema.html">

Reference: XML Sitemap rendering as plain text

Golgotha answered 6/1, 2021 at 15:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.