jakejgordon
jakejgordon

Reputation: 4098

XSD For Sitemap with HREFLANG

We are launching a major website with support for 20 languages and tons of regional content (i.e. content that is targeted to a specific country or set of countries). As such, we have a textbook use case for using xhtml:link with rel='hreflang' in our sitemap. We generally prefer to generate classes from an XSD so that we can programmatically generate the XML that is guaranteed compliant. I was hoping to find an updated XSD that includes xhtml:link in the definitions. However, I keep getting pointed back to the base sitemap xsd: http://www.sitemaps.org/schemas/sitemap/sitemap.xsd , which has no support for xhtml:link (defined in xhtml-link-1.xsd).

It looks like Google just supports an xhtml:link element with it's supported attributes, but before I try to modify the basic sitemap.xsd by hand to include this, I wanted to see if anyone has taken the time to publish an XSD that already has http://www.sitemaps.org/schemas/sitemap/0.9 and http://www.w3.org/1999/xhtml included? If so, could you point me in the right direction? Or if I'm headed down the wrong path here for some reason I also appreciate being steered in the right direction. Thanks in advance for the help!

Upvotes: 5

Views: 2090

Answers (3)

Fleshgrinder
Fleshgrinder

Reputation: 16253

I had the same problem and I found a solution. Download all XSDs to your local drive and create a new XSD file that imports all the namespaces.

<?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>

Upvotes: 0

g5insider
g5insider

Reputation: 119

If you change the namespace to xmlns:xhtml="http://www.w3.org/TR/xhtml11/xhtml11_schema.html" which was suggested by @datahell you will receive a namespace warning from google when trying to validate your sitemap.

You should use the one that google has in their example. This will cause your links to look like straight text on a webpage which is not very appealing.

You may or may not want to style your xml.

Happy Multilingual Sitemapping!

Upvotes: 2

datahell
datahell

Reputation: 79

Sitemap guides with hreflang from google are wrong. The sitemap doesn't validate as the xhtml:link does not exist in namespace.

Change namespace to the one below and it will validate.

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

Upvotes: 7

Related Questions