gpt4 book ai didi

xml - 使用 xhtml :link inside url element 验证 XML 站点地图 urlset

转载 作者:数据小太阳 更新时间:2023-10-29 02:34:10 27 4
gpt4 key购买 nike

我正在尝试创建如下所示的站点地图,但出现此错误:

 <?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"> ^ 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.

请指教。谢谢。

最佳答案

本文档有两个问题:

  1. schemaLocation 属性必须位于 XML 架构实例命名空间中。

  2. 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>

关于xml - 使用 xhtml :link inside url element 验证 XML 站点地图 urlset,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36193346/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com