Sta*_*ser 6 xml sitemap xhtml xsd xml-namespaces
我正在尝试创建如下所示的站点地图,但出现此错误:
<?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>
Run Code Online (Sandbox Code Playgroud)
错误:
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.w3.org/1999/xhtml }link':没有匹配的全局元素声明可用,但严格通配符要求。
请指教。谢谢你。
这个文档有两个问题:
schemaLocation 属性必须在 XML 架构实例命名空间中。
url 元素无效,因为它的定义说明processContents="strict"
了 XHTML 的模式丢失,因此在范围内没有 xhtml:link 声明。
<?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>
Run Code Online (Sandbox Code Playgroud)小智 7
旧的 - 但在搜索时仍然会出现。实际上问题是您正在使用 xhtml:link 然后您需要“其他”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">
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5652 次 |
最近记录: |