多语言网站地图出现验证错误:“没有匹配的全局元素声明可用”

8
我一直在尝试遵循Google的多语言站点地图建议。然而,当我在我的网站上尝试时,我收到以下错误消息:

错误1845:元素'{http://www.w3.org/1999/xhtml}link':没有匹配的全局元素声明可用,但被严格通配符要求。

即使我将Google的示例粘贴到站点地图验证器中,我也会收到同样的错误。这里有什么我漏掉的吗?
这是我一直在粘贴到验证器中的Google示例:
<?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">
  <url>
    <loc>http://www.example.com/english/</loc>
    <xhtml:link 
                 rel="alternate"
                 hreflang="de"
                 href="http://www.example.com/deutsch/"
                 />
    <xhtml:link 
                 rel="alternate"
                 hreflang="de-ch"
                 href="http://www.example.com/schweiz-deutsch/"
                 />
    <xhtml:link 
                 rel="alternate"
                 hreflang="en"
                 href="http://www.example.com/english/"
                 />
  </url>

  <url>
    <loc>http://www.example.com/deutsch/</loc>
    <xhtml:link 
                 rel="alternate"
                 hreflang="en"
                 href="http://www.example.com/english/"
                 />
     <xhtml:link 
                 rel="alternate"
                 hreflang="de-ch"
                 href="http://www.example.com/schweiz-deutsch/"
                 />
     <xhtml:link 
                 rel="alternate"
                 hreflang="de"
                 href="http://www.example.com/deutsch/"
                 />
  </url>

  <url>
    <loc>http://www.example.com/schweiz-deutsch/</loc>
     <xhtml:link 
                 rel="alternate"
                 hreflang="de"
                 href="http://www.example.com/deutsch/"
                 />
     <xhtml:link 
                 rel="alternate"
                 hreflang="en"
                 href="http://www.example.com/english/"
                 />
<xhtml:link 
                 rel="alternate"
                 hreflang="de-ch"
                 href="http://www.example.com/schweiz-deutsch/"
                 />
  </url>

</urlset> 

1
你使用哪个验证器? - unor
http://tools.seochat.com/tools/site-validator/ - pocockn
2个回答

4
在您的xhtml命名空间定义末尾添加一个/,如下所示: <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml/">/

这是不正确的。XML 命名空间名称是"作为字符串进行比较",因此添加斜杠将描述不同的命名空间。命名空间名称不必"可用于检索模式"。XHTML的命名空间名称是"http://www.w3.org/1999/xhtml"。 - Florian
这个没有通过我找到的任何网站地图验证器,请问你有证据表明它有效吗? - Alex

4

1
那么哪个在线资源更适合验证呢?因为我有同样的问题,不确定我的站点地图是否有效。谢谢! - LINKeRxUA
1
@LINKeRxUA: 你可以在[softwarerecs.se]上问,因为在 Stack Overflow 这里,推荐已经是不适合讨论的话题了。 - unor

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接