带有HREFLANG的站点地图的XSD

时间:2013-05-28 18:31:53

标签: seo xsd sitemap

我们正在推出一个主要网站,支持20种语言和大量区域内容(即针对特定国家或国家/地区的内容)。因此,我们有一个教科书用例,用于在我们的站点地图中使用xhtml:link with rel ='hreflang'。我们通常更喜欢从XSD生成类,以便我们可以以编程方式生成符合保证的XML。我希望在定义中找到包含xhtml:link的更新XSD。但是,我一直指向基站点地图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的内容?如果是这样,你能指出我正确的方向吗?或者如果我出于某种原因走错了路,我也很欣赏被引导到正确的方向。在此先感谢您的帮助!

3 个答案:

答案 0 :(得分:7)

来自谷歌的hreflang的站点地图指南是错误的。站点地图未验证,因为命名空间中不存在xhtml:链接。

将名称空间更改为下面的名称空间,它将验证。

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

答案 1 :(得分:1)

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

你应该使用google在他们的例子中使用的那个。这将导致您的链接看起来像网页上的直文,这不是很吸引人。

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

快乐的多语言站点地图!

答案 2 :(得分:0)

我有同样的问题,我找到了解决方案。将所有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>