【问题标题】:XSD For Sitemap with HREFLANGXSD 用于带有 HREFLANG 的站点地图
【发布时间】:2013-05-23 20:00:01
【问题描述】:

我们正在推出一个支持 20 种语言和大量区域内容(即针对特定国家或一组国家的内容)的主要网站。因此,我们有一个教科书用例在我们的站点地图中使用 xhtml:link 和 rel='hreflang'。我们通常更喜欢从 XSD 生成类,以便我们可以以编程方式生成保证兼容的 XML。我希望找到一个更新的 XSD,其中包含 xhtml:link 在定义中。但是,我一直被指向基本站点地图 xsd:http://www.sitemaps.org/schemas/sitemap/sitemap.xsd,它不支持 xhtml:link(在 xhtml-link-1.xsd 中定义)。

看起来 Google 只支持 xhtml:link 元素及其支持的属性,但在我尝试手动修改基本的 sitemap.xsd 以包含它之前,我想看看是否有人花时间发布 XSD已经包含http://www.sitemaps.org/schemas/sitemap/0.9http://www.w3.org/1999/xhtml?如果是这样,你能指出我正确的方向吗?或者,如果我出于某种原因在这里走错了路,我也很感激被引导到正确的方向。提前感谢您的帮助!

【问题讨论】:

  • 看起来不太有希望。如果我最终走修改 XSD 的路线,我一定会发布它以防其他人想要它...

标签: seo xsd sitemap


【解决方案1】:

来自 google 的带有 hreflang 的站点地图指南是错误的。由于命名空间中不存在 xhtml:link,因此站点地图无法验证。

将命名空间更改为以下名称,它将验证。

xmlns:xhtml="http://www.w3.org/TR/xhtml11/xhtml11_schema.html"

【讨论】:

  • 感谢您的评论。再过一两周我将切换回站点地图工作,届时我会回来更新我的发现。
【解决方案2】:

如果您将命名空间更改为 @datahell 建议的 xmlns:xhtml="http://www.w3.org/TR/xhtml11/xhtml11_schema.html" ,您将在尝试验证时收到来自 google 的命名空间警告您的站点地图。

您应该使用 google 在他们的示例中提供的那个。这将导致您的链接看起来像网页上的纯文本,不太吸引人。

您可能想要也可能不想为您的 xml 设置样式。

快乐的多语言站点映射!

【讨论】:

    【解决方案3】:

    我遇到了同样的问题,我找到了解决方案。将所有 XSD 下载到本地驱动器并创建一个新的 XSD 文件来导入所有命名空间。

    <?xml version="1.0" encoding="utf-8"?>
    <xsd:schema xmlns="http://symfony.com/schema"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                targetNamespace="http://symfony.com/schema"
                elementFormDefault="qualified">
        <!--
            The Sitemap schema does not include the link element that is
            utilized by Google for multi-language Sitemaps. Hence, we need
            to combine the two schemas for automated validation in a dedicated
            XSD.
        -->
        <xsd:import namespace="http://www.sitemaps.org/schemas/sitemap/0.9"
                    schemaLocation="sitemap.xsd"/>
        <xsd:import namespace="http://www.w3.org/1999/xhtml"
                    schemaLocation="xhtml1-strict.xsd"/>
    </xsd:schema>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-10-12
      • 2014-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-01
      相关资源
      最近更新 更多