使用 url 元素内的 xhtml:link 验证 XML 站点地图 urlset [英] 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>
错误:
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"> ^ 错误 1866:元素 '{http://www.sitemaps.org/schemas/sitemap/0.9}urlset',属性'{http:///www.w3.org/1999/xhtml}schemaLocation':属性'{http://www.w3.org/1999/xhtml}schemaLocation' 是不允许的.在线:3
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': 没有可用的匹配全局元素声明,但严格通配符要求.
'{http://www.w3.org/1999/xhtml}link': No matching global element declaration available, but demanded by the strict wildcard.
请指教.谢谢.
推荐答案
本文档有两个问题:
schemaLocation 属性必须在 XML 架构实例命名空间中.
The schemaLocation attribute must be in the XML Schema Instance namespace.
url 元素无效,因为它的定义是 processContents="strict"
并且缺少 XHTML 的架构,因此在范围内没有 xhtml:link 声明.
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>
这篇关于使用 url 元素内的 xhtml:link 验证 XML 站点地图 urlset的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!