Oded V Streigold
Oded V Streigold

Reputation: 83

Validating sitemap with Google image indexing

I'm trying to validate this sitemap: http://animal.org.il/post.xml using this validation tool: http://www.xmlcheck.com/checkurl.php

I'm getting this error on all the image:image tages: Error 1845: Element '{http://www.google.com/schemas/sitemap-image/1.1}image': No matching global element declaration available, but demanded by the strict wildcard.

Here is a snippet of the current source of my sitemap showing some of those image:image tags:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="http://animal.org.il/wp-content/plugins/bwp-google-xml-sitemaps/xsl/bwp-sitemap.xsl"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">

<url>
    <loc>http://animal.org.il/to-be-goose/</loc>
    <lastmod>2012-07-24T09:57:18+00:00</lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.4</priority>
    <image:image>
      <image:loc>http://animal.org.il/wp-content/gallery/goose/goose-nature.jpg</image:loc>
      <image:title>אווז בטבע</image:title>
      <image:caption>אווז בטבע עף על פני מאות קילומטרים מדי שנה, אך בתעשיית הבשר והנוצות הוא לא יזכה לפרוש כנף לעולם.</image:caption>
    </image:image>
    <image:image>
      <image:loc>http://animal.org.il/wp-content/gallery/goose/goose-feathers.jpg</image:loc>
      <image:title>תעשיית הנוצות</image:title>
      <image:caption>אווז ממשש במקורו את העור החשוף לאחר מריטת נוצותיו. מתוך תחקיר על תעשיית ה&lt;a href="http://anonymous.org.il/cat40.html" target="_blank"&gt;נוצות&lt;/a&gt; של הטלוויזיה השוודית (Kalla Fatka, TV4)</image:caption>
    </image:image>
    <image:image>
      <image:loc>http://animal.org.il/wp-content/gallery/goose/goose-foie-gras.jpg</image:loc>
      <image:title>כך מייצרים כבד אווז</image:title>
      <image:caption>על מנת לייצר &lt;a href="http://anonymous.org.il/cat14.html" target="_blank"&gt;כבד אווז&lt;/a&gt;, מפטמים את האווז באמצעות החדרת צינור מתכת לגרונו.</image:caption>
    </image:image>
  </url>

Upvotes: 1

Views: 3035

Answers (1)

C. M. Sperberg-McQueen
C. M. Sperberg-McQueen

Reputation: 25034

By default, the validation service you are using seems to be using the sitemap schema at http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd to validate the sitemap document. That schema has a wildcard that will match your image:image elements, but those elements are declared in a separate schema document at http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd and not in the schema being used. As the error message says, the wildcard in question is a 'strict' one, meaning the elements it matches must be declared in the schema.

There may be a way to tell the validator to consult the schema document for the image namespace, but I could not see any obvious one. You could add an xsi:schemaLocation attribute to your sitemap document, so your root element looks like this:

<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" 
  xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
  xsi:schemaLocation="
    http://www.sitemaps.org/schemas/sitemap/0.9
    http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd
    http://www.google.com/schemas/sitemap-image/1.1
    http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd" >

This is not usually the best way to tell a schema validator where to find the schema, but it often works. Not in this case, however.

On the other hand, for documents you upload, the validation service you are using allows you also to upload a schema document. If you make a schema document that just imports the two schema documents you want, for the sitemap and sitemap-image namespaces, as shown below, and upload it along with your sitemap, your errors with the image elements go away. If you are validating your sitemap from the Web, and not by uploading it, there may be another way to get the validator to use the right schema; you'll have to look for documentation or ask the operators of the service for information.

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:import namespace="http://www.sitemaps.org/schemas/sitemap/0.9"
             schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"/>
  <xs:import namespace="http://www.google.com/schemas/sitemap-image/1.1"
             schemaLocation="http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd"/>

</xs:schema>

In their place, you have errors complaining about the image:caption element, which should precede, not follow, image:title. When those are fixed, your site map is recognized as valid.

Upvotes: 10

Related Questions